Article View: borland.public.cppbuilder.nativeapi
Article #17326Re: ShellExecute
From: Remy Lebeau (TeamB)
Date: Thu, 03 Apr 2003 18:08
Date: Thu, 03 Apr 2003 18:08
37 lines
2182 bytes
2182 bytes
"RaynorPao" <RaynorPao.nospam@nospam.pchome.com.tw> wrote in message
news:3e8c5dce@newsgroups.borland.com...
> if(!EnumWindows((WNDENUMPROC)MyEnumWndProc, (LPARAM)hinst))
> {
> // It didn't execute to this block.
Nor should it. You made the wrong assumption. You assume that
EnumWindows() returns the same return value as the callback function. It
doesn't. The callback's return value simply tells EnumWindows() whether to
continue enumerating to the next window or not, whereas the return value of
EnumWindows() tells the calling code whether the enumeration itself was
successfully executed or not.
Try this instead:
void __fastcall TForm1::Button3Click(TObject *Sender)
{
HINSTANCE hinst = ShellExecute(NULL, "open", "test.txt", NULL, NULL,
SW_SHOWNORMAL);
if( hinst > 32 )
{
ghwnd = NULL;
EnumWindows((WNDENUMPROC)MyEnumWndProc, (LPARAM)hinst);
if( ghwnd != NULL )
{
char szCaption[256]={0};
GetWindowText(ghwnd, szCaption, 256);
ShowMessage(szCaption);
}
}
}
Gambit
Technical Details
Message-ID:
<3e8c78bd$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3e8c0ea4@newsgroups.borland.com> <3e8c5793$1@newsgroups.borland.com> <3e8c5dce@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,bff1fa0e8e8777f2 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-03 11:02:13 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3e8c0ea4@newsgroups.borland.com> <3e8c5793$1@newsgroups.borland.com> <3e8c5dce@newsgroups.borland.com> Subject: Re: ShellExecute Date: Thu, 3 Apr 2003 10:08:08 -0800 Lines: 39 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3e8c78bd$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1049393341 207.175.226.26 (3 Apr 2003 10:09:01 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail