Click here to Skip to main content
16,008,750 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Tab order Pin
Ravi Bhavnani10-Dec-01 4:52
professionalRavi Bhavnani10-Dec-01 4:52 
GeneralRe: Tab order Pin
andysolman10-Dec-01 23:54
andysolman10-Dec-01 23:54 
GeneralRe: Tab order Pin
Ravi Bhavnani11-Dec-01 1:53
professionalRavi Bhavnani11-Dec-01 1:53 
GeneralCreateProcess Pin
HF10-Dec-01 4:30
HF10-Dec-01 4:30 
GeneralRe: CreateProcess Pin
Jon Hulatt10-Dec-01 5:18
Jon Hulatt10-Dec-01 5:18 
GeneralRe: CreateProcess Pin
HF12-Dec-01 0:06
HF12-Dec-01 0:06 
GeneralRe: CreateProcess Pin
HF12-Dec-01 3:26
HF12-Dec-01 3:26 
GeneralRe: CreateProcess Pin
Lim Bio Liong12-Dec-01 18:36
Lim Bio Liong12-Dec-01 18:36 
Hello HF,

I tried 4 separate scenarios with different results. The following is a summary :

1. Using your original code :
if (!CreateProcess(NULL,(LPSTR)param,NULL,NULL,TRUE,NORMAL_PRIORITY_CLASS,NULL,NULL,&startup_info,&proc_info))

1.1 param would hold the string "testapp.exe param1, param2"
1.2 This code works fine.
1.3 I used a sample MFC app for launching.
1.4 CWinApp::m_lpCmdLine points to the parameters correctly (i.e. "param1, param2").



2. Putting "param" as the first parameter :

if (!CreateProcess(param,(LPSTR)NULL,NULL,NULL,TRUE,NORMAL_PRIORITY_CLASS,NULL,NULL,&startup_info,&proc_info))

2.1 param would hold the string "testapp.exe param1, param2"

2.2 This time the CreateProcess() API failed.

2.3 GetLastError() returned value 2 ("The system cannot find the file specified.") which implies strongly that the entire string "testapp.exe param1, param2" is taken as the program name.

2.4 I believe you are already aware of this.



3. Putting the app name as the first parameter and the command line as the second :

char process[256], parameter[256];
strcpy(process,(LPCTSTR)nom_fic_exec);
strcpy(parameter,(LPCTSTR)paramstring);
if (!CreateProcess((LPCTSTR)process,(LPTSTR)parameter,NULL,NULL,TRUE,NORMAL_PRIORITY_CLASS,NULL,NULL,&startup_info,&proc_info))

3.1 process holds the string "TestApp.exe"
parameter holds the string "param1, param2".

3.2 This time, very strangely, CWinApp::m_lpCmdLine holds "param2". But when I call GetCommandLine() in TestApp, the returned string is "param1, param2".



4. Finally, I used the same style as (3) but put a space character at the beginning of the string parameter :

char process[256], parameter[256];
strcpy(process,(LPCTSTR)nom_fic_exec);
strcpy(parameter, " ");
strcat(parameter,(LPCTSTR)paramstring);
if (!CreateProcess((LPCTSTR)process,(LPTSTR)parameter,NULL,NULL,TRUE,NORMAL_PRIORITY_CLASS,NULL,NULL,&startup_info,&proc_info))

4.1 process holds the string "TestApp.exe"
parameter holds the string "param1, param2".

4.2 This time, CWinApp::m_lpCmdLine holds "param1, param2". And GetCommandLine() returned the string " param1, param2" (a space at the front).


I believe using GetCommandLine() instead of using CWinApp::m_lpCmdLine may be a good alternative.

Hope the above helps, HF.


Regards,
Bio.



GeneralRe: CreateProcess Pin
HF13-Dec-01 3:47
HF13-Dec-01 3:47 
GeneralRe: CreateProcess Pin
Lim Bio Liong13-Dec-01 19:40
Lim Bio Liong13-Dec-01 19:40 
GeneralNon Client Painting Pin
Jon Hulatt10-Dec-01 4:29
Jon Hulatt10-Dec-01 4:29 
GeneralRe: Non Client Painting Pin
Ravi Bhavnani11-Dec-01 5:28
professionalRavi Bhavnani11-Dec-01 5:28 
GeneralCropping A DIB Pin
AJ12310-Dec-01 3:24
AJ12310-Dec-01 3:24 
GeneralRe: Cropping A DIB Pin
Chris Losinger10-Dec-01 4:35
professionalChris Losinger10-Dec-01 4:35 
GeneralMySQL HELP! Pin
Bill Gates Antimatter Particle10-Dec-01 1:43
Bill Gates Antimatter Particle10-Dec-01 1:43 
GeneralRe: MySQL HELP! Pin
Jon Hulatt10-Dec-01 4:30
Jon Hulatt10-Dec-01 4:30 
GeneralPrinting bitmap fails, but preview ok Pin
9-Dec-01 23:24
suss9-Dec-01 23:24 
GeneralRe: Printing bitmap fails, but preview ok Pin
Ravi Bhavnani10-Dec-01 4:14
professionalRavi Bhavnani10-Dec-01 4:14 
GeneralRe: Printing bitmap fails, but preview ok Pin
11-Dec-01 2:34
suss11-Dec-01 2:34 
GeneralRe: Printing bitmap fails, but preview ok Pin
11-Dec-01 4:03
suss11-Dec-01 4:03 
GeneralRe: Printing bitmap fails, but preview ok Pin
Chris Losinger11-Dec-01 4:19
professionalChris Losinger11-Dec-01 4:19 
GeneralData binding with grid control Pin
imranqau9-Dec-01 21:37
imranqau9-Dec-01 21:37 
QuestionHow can I connect to a dialog in other class? Pin
zrsoft9-Dec-01 20:26
zrsoft9-Dec-01 20:26 
AnswerRe: How can I connect to a dialog in other class? Pin
#realJSOP10-Dec-01 5:02
professional#realJSOP10-Dec-01 5:02 
QuestionFolder/File Size?!? Pin
Greven9-Dec-01 13:17
Greven9-Dec-01 13:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.