|
-
November 18th, 2009, 12:32 PM
#1
Using command line help
I want to copy a file. I would like it so i can give the argument in command line and that would be the file name of the copied one. But when i run it with the argument, nothing happens. Also, can i set "lpCmdLine" to have a default value when no value is assigned to it? Thanks for help!
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
lpCmdLine = (LPSTR)GetCommandLine();
CopyFile(L"lol.txt", (LPCWSTR)lpCmdLine, FALSE);
return 0;
}
-
November 23rd, 2009, 04:09 AM
#2
Re: Using command line help
I am not sure if it is a good thing to call GetCommandLine(). This will override the content of lpCmdLine. This is a pity since lpCmdLine is already containing your command line. You can see what is in this variable, with
Code:
FILE *log_fp; log_fp = fopen(log_file, "wt"); fprintf(log_fp, lpCmdLine); fclose(log_fp);
-
November 24th, 2009, 08:07 PM
#3
Re: Using command line help
To convert the command line to an argv style array of strings, call CommandLineToArgvW which is explained at GetCommandLine
-
December 3rd, 2009, 05:08 AM
#4
Re: Using command line help
You can use the global variables __argc and __argv (and probably __envp), which contain the cmdline arguments like in a standard C program
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|