Article View: borland.public.cppbuilder.nativeapi
Article #16821ShellExecuteEx and WaitForSingle Object Problem
From: ahmoy
Date: Fri, 25 Apr 2003 22:08
Date: Fri, 25 Apr 2003 22:08
27 lines
1708 bytes
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
Technical Details
Message-ID:
<3ea8dcc4@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5d082747710f881,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-25 00:02:10 PST From: "ahmoy" <ahmoy_law@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: ShellExecuteEx and WaitForSingle Object Problem Date: Fri, 25 Apr 2003 15:08:33 -0700 Lines: 34 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 210.19.106.156 Message-ID: <3ea8dcc4@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1051253956 210.19.106.156 (24 Apr 2003 23:59:16 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail