Reputation: 7131
How can I make a Win32 application open a file at startup when calling it like this (e.g. with a shortcut or via command line)?
program.exe "document.txt"
Upvotes: 1
Views: 442
Reputation: 39000
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.
Upvotes: 2
Reputation: 19349
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
Upvotes: 3