How can I make a Win32 application open a fi开发者_开发百科le at startup when calling it like this (e.g. with a shortcut or via command line)?
program.exe "document.txt"
This link shows how to retrieve command line arguments and turn them into an array of string
Even though it is written in a main
, it works equally well in WinMain
or any other function
If you have a Unicode program use lpCmdLine
, otherwise use GetCommandLineW
and pass the result to CommandLineToArgvW
to get a list of strings for the arguments to the program, then it works just like with a command-line program.
精彩评论