Problems with Command Line Args in MFC App
I read a few of the posts on this after doing a search but didn't see my situation in them.
My situation is wanting to receive 2 strings.
1. a path with c:\Program Files\.....
2. a DLL to register using RegAsm.exe through the use of WaitForSingleObject and SHELLEXECUTEINFO STRUCT.
The problem I am running into is with the command CommandLineToArgvW()
see below (path is first)
Code:
szArgList = CommandLineToArgvW(lpCmdLine, &argCount);
Register the com dll in directory sent in in lpCmdLine
CString sDllName = szArgList[1];
sDllName += " /Silent";
CString sExeDir = szArgList[0];
The sDllName is good but...
No matter what I have tried sExeDir ends up being "c:\Progam" and the space is cutting off full path name , ,,,because of wide char function?
I also noticed _UNICODE is defined and I dont remember doing that.
How would you do this? Differently?
Oh one other thing, I noticed that it works fine when commandline is supplied and run in Visual Studio but not when app is run separately and values are supplied through Start and Run in windows. Strange and frustrating. Don't understand.
Re: Problems with Command Line Args in MFC App
You didn't show how you start it from the command line, but try enclosing your command line arguments in quotes:
Code:
C:\Myapp>myexe "C:\Program Files\MyDir\argfile.txt"
Normally, each argument is separated by a space, but since this ONE argument actually contains a space, you need to enclose it in quotes.
Hope that helps.
Re: Problems with Command Line Args in MFC App
Yea I did that.
In debug both args 0 , and 1 appear full strings but when assigned into CString vars is where the trouble begins.
I may have to post the project to show what I mean.