Pass main() Commands In WinMain() Function
May 10, 2017 at 5:16am UTC
Hello everyone,
I have the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
int main(int argc, char * argv[])
{
if (argc!=3)
{
exit(1);
}
in=fopen(argv[1], "rb" );
if (!in)
{
exit(1);
}
out=fopen(argv[2], "wb" );
if (!out)
{
exit(1);
}
run();
fclose(in);
fclose(out);
return 0;
}
Now, I want this to be a WinMain() function instead, so I change it to:
1 2 3 4 5 6 7
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
}
So, what I want to do is pass the following main() command in my WinMain function:
program.exe file1 file2
This will execute the run() function of my program with both arguments as "file1" and "file2".
How can I do this?
May 10, 2017 at 6:07am UTC
May 10, 2017 at 11:12am UTC
There is __argc and __argv global variables defined automatically by the C runtime. These are not standard, but it works.
May 10, 2017 at 1:50pm UTC
Thanks for the responses guys.
I will give these suggestions a try and see which works best.
Topic archived. No new replies allowed.