🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17324

Re: ShellExecute

#17324
From: RaynorPao
Date: Thu, 03 Apr 2003 18:48
68 lines
2902 bytes
Hi Remy:

I modified my code as below:

void __fastcall TForm1::Button3Click(TObject *Sender)
{
   HINSTANCE hinst=ShellExecute(NULL, "open", "test.txt", NULL, NULL,
SW_SHOWNORMAL);
   if((int)hinst>32)
   {
      ghwnd=NULL;
      EnumWindows((WNDENUMPROC)MyEnumWndProc, (LPARAM)hinst);
      if(ghwnd!=NULL)
      {
         char szCaption[256]={0};
         GetWindowText(ghwnd, szCaption, 256);
         ShowMessage(szCaption);
      }
   }
}

But, it still can't find the window which is created with ShellExecute.
Is there something wrong what I do? Please help me.

Thanks.
RaynorPao.

"Remy Lebeau (TeamB)" <gambit47@yahoo.com> ���g��l��
news:3e8c78bd$1@newsgroups.borland.com...
>
> "RaynorPao" <RaynorPao.nospam@nospam.pchome.com.tw> wrote in message
> news:3e8c5dce@newsgroups.borland.com...
>
>
> 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: <3e8c7e29@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3e8c0ea4@newsgroups.borland.com> <3e8c5793$1@newsgroups.borland.com> <3e8c5dce@newsgroups.borland.com> <3e8c78bd$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10cc67,bff1fa0e8e8777f2
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-04-03 10:38:07 PST
From: "RaynorPao" <RaynorPao.nospam@nospam.pchome.com.tw>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3e8c0ea4@newsgroups.borland.com> <3e8c5793$1@newsgroups.borland.com> <3e8c5dce@newsgroups.borland.com> <3e8c78bd$1@newsgroups.borland.com>
Subject: Re: ShellExecute
Date: Fri, 4 Apr 2003 02:48:31 +0800
Lines: 70
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
NNTP-Posting-Host: 61.221.176.28
Message-ID: <3e8c7e29@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1049394729 61.221.176.28 (3 Apr 2003 10:32:09 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail