Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
How to Emb an another program in a open window? Now I have a try, but still have some problem, 
1,how do I know when the loading program load success
2,when sleep is short, loading program will open but not embed to specified window


What I have tried:

I have used CreateProcess & FindWindow & SetWindowLong & SetParent & SetWindowPos funcs
Posted
Updated 7-Oct-16 21:01pm

1 solution

Given you dont show us any code its a bit of a guess for us as to how to help you. In short, if you're using

PROCESS_INFORMATION processInformation = {0};


in your call to CreateProcess, you can then

WaitForSingleObject( processInformation.hProcess, INFINITE );
DWORD exitCode;
BOOL result = GetExitCodeProcess(processInformation.hProcess, &exitCode);
 
Share this answer
 
Comments
Member 11768554 8-Oct-16 3:05am    
BOOL fsuccess=CreateProcess(NULL,//lpApplicationName
pathexe, //lpCommanderLine
NULL, //lpProcessAttributes
NULL, //lpThreadAttributes
FALSE, //bInheritHandles
NORMAL_PRIORITY_CLASS,//dwCreationFlags
NULL, //lpEnvironment
NULL, //lpCurrentDirectory
&sinfo, //lpStartupInfo
&pinfo); //lpProcessInformation
// wait for NotePad finishes
if(fsuccess)
{
HANDLE hProcess=pinfo.hProcess;
CloseHandle(pinfo.hThread);// close thread at once
if (bWait)
{
DWORD dw = WaitForSingleObject(hProcess,INFINITE);
if (dw !=WAIT_FAILED)
{
DWORD dwExitCode;
GetExitCodeProcess(hProcess,&dwExitCode);
if (dwExitCode==STILL_ACTIVE) AfxMessageBox("IDS_NOTEPAD_ALIVE");
}
}

CloseHandle(pinfo.hProcess);
}


when I debug "DWORD dw = WaitForSingleObject(hProcess,INFINITE);" . it will wait infinite, though another program open sucessfully. When I close loading program, it can goto next line.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900