LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can not call "CreateProcess()" API normaly

In my application , there are 2 menuitems corresponding to the different calls . One is call a panel which can process file I/O ,and the other uses "CreateProcess()" to launch another application .

If first time call CreateProcess() , it can launch application correctly , but once first time active the file I/O calling instead of activing it ,after close the file I/O panel ,then call the CreateProcess(), it always return zero . The CreateProcess() is coading as :
...
STARTUPINFO si ;
PROCESS_INFORMATION piProcess;

ZeroMemory(&si,sizeof(si));
si.cb = sizeof(si);

CreateProcess("Myfile.exe",my Comand line,NULL,NULL,FALSE,CREATE_DEFAULT_ERROR_MODE|DETACHED_PROCESS,NULL,my process location,&si,&piProcess);
...

Can any
one tell me what is wrong ? Thanks.

David
0 Kudos
Message 1 of 2
(2,927 Views)
The problem has been solved . The reason is that when call the file I/O application , the process access directory is changed ,so when launch another desired application by "CreateProcess()", due to the incorrect path , it can not locate the application .The correct way is that before call "CreateProcess()", use "GetCurrentDirectory()" to validate if the path would be changed ,if it is , use "SetCurrentDirectory()" to direct the correct path ,then call "CreateProcess()" , thus , everything is OK !

David
0 Kudos
Message 2 of 2
(2,927 Views)