🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: ShellExecute

#17343
From: RaynorPao
Date: Fri, 04 Apr 2003 03:46
56 lines
2595 bytes
Hi Remy & nicolasr:

Thanks for your reply.
I modified my code as below:

HWND ghwnd;
BOOL CALLBACK MyEnumWndProc(HWND hWnd, LPARAM lParam);

BOOL CALLBACK MyEnumWndProc(HWND hWnd, LPARAM lParam)
{
   HINSTANCE hInst=(HINSTANCE)lParam;
   HINSTANCE hGetInst=(HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
   if(hInst==hGetInst)
   {
      ghwnd=hWnd;
      return FALSE;
   }
   return TRUE;
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   SHELLEXECUTEINFO ShlInfo;
   ZeroMemory(&ShlInfo, sizeof(SHELLEXECUTEINFO));
   ShlInfo.cbSize=sizeof(SHELLEXECUTEINFO);
   ShlInfo.fMask=SEE_MASK_NOCLOSEPROCESS;
   ShlInfo.hwnd=this->Handle;
   ShlInfo.lpVerb="open";
   ShlInfo.lpFile="test.txt";
   ShlInfo.lpParameters=NULL;
   ShlInfo.lpDirectory=NULL;
   ShlInfo.nShow=SW_SHOWNORMAL;
   ShellExecuteEx(&ShlInfo);

   if(!EnumWindows((WNDENUMPROC)MyEnumWndProc, (LPARAM)ShlInfo.hInstApp))
   {
      // This time, it can execute to this block, but got a wrong window
      char szCaption[256]={0};
      GetWindowText(ghwnd, szCaption, 256);
      ShowMessage(szCaption);
   }
}

But, it still can't get the HWND which is created with ShellExecuteEx.
Please help me.

Thanks.
RaynorPao.


"nicolasr" <nicolasrNOSPAMATSIGNgmx.net> ���g��l��
news:3e8cb03c@newsgroups.borland.com...
> thanks, good to know.
> Nick
>
>
Technical Details
Message-ID: <3e8cfc38@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-08!supernews.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3e8c0ea4@newsgroups.borland.com> <3e8c5793$1@newsgroups.borland.com> <3e8c5dce@newsgroups.borland.com> <3e8c7d44@newsgroups.borland.com> <3e8c8d8f$1@newsgroups.borland.com> <3e8c9481$1@newsgroups.borland.com> <3e8ca60e$2@newsgroups.borland.com> <3e8cb03c@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 19:30:50 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> <3e8c7d44@newsgroups.borland.com> <3e8c8d8f$1@newsgroups.borland.com> <3e8c9481$1@newsgroups.borland.com> <3e8ca60e$2@newsgroups.borland.com> <3e8cb03c@newsgroups.borland.com>
Subject: Re: ShellExecute
Date: Fri, 4 Apr 2003 11:46:23 +0800
Lines: 58
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: <3e8cfc38@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1049427000 61.221.176.28 (3 Apr 2003 19:30:00 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail