🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
1 messages
1 total messages Started by ahmoy Fri, 25 Apr 2003 22:08
ShellExecuteEx and WaitForSingle Object Problem
#16821
Author: ahmoy
Date: Fri, 25 Apr 2003 22:08
27 lines
1708 bytes
BOOL  ShellExecAndWait ( TCHAR* szAppName, TCHAR* szParam )
{
 SHELLEXECUTEINFO stExeInfo;

 memset ( &stExeInfo, 0, sizeof(stExeInfo) );
 stExeInfo.cbSize = sizeof(stExeInfo);
 stExeInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
 stExeInfo.lpVerb = L"open";
 stExeInfo.lpFile = szAppName;
 stExeInfo.lpParameters = szParam;

 if ( !ShellExecuteEx ( &stExeInfo ) ) return FALSE;
 if ( WaitForSingleObject ( stExeInfo.hProcess, INFINITE ) == WAIT_FAILED )
return FALSE;
 if ( !CloseHandle ( stExeInfo.hProcess ) ) return FALSE;    // <---
problem!

 return TRUE;
}

the problem is at the CloseHandle line, CloseHandle returns FALSE and
GetLastError returns Invalid handle code.  but if i use CreateProcess then
CloseHandle for process and thread handle works without error.  somebody got
any clue?

thanks in advance,
ahmoy law
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads