🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: ShowWindow question

#13291
From: Martin C
Date: Sat, 18 Oct 2003 21:29
65 lines
2560 bytes
Hi Bob,

First of all thank you for your help, please find below full code for the
function SearchProgramHandl()



HWND __fastcall TForm1::SearchProgramHandl(AnsiString ExeNameToHide)
{
 HANDLE SysResHandl, RProgHandl;
 PROCESSENTRY32 Proc;
 String SRExename;

 RProgHandl=0;

 SysResHandl = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

  if (SysResHandl == INVALID_HANDLE_VALUE)
  {  return 0; } else { }

  try
  {
    Proc.dwSize = sizeof(Proc);
    if(Process32First(SysResHandl, &Proc))
    {
      do
      {
            SRExename = ExtractFileName(Proc.szExeFile); //Get the First Exe
Name
             //Compare found Exe Name with the ExeNameToHide

             if(UpperCase(Trim(ExeNameToHide))==UpperCase(Trim(SRExename)) )
              {  RProgHandl = OpenProcess(PROCESS_ALL_ACCESS, true,
Proc.th32ProcessID); // Get Exe Handle
              }
              else
              {  RProgHandl=0;
              }
      }while(Process32Next(SysResHandl, &Proc));
    }
    else
    { RProgHandl=0;
    }
  }
  __finally
  {  CloseHandle(SysResHandl);
  }

  return RProgHandl;
}
//--------------------------------------------------------------------------
-

BR


"Bob Gonder" <notbg@notmindspring.invalid> wrote in message
news:srq1pvg3emp51jq97kjt2tkaqv8uoa5cpm@4ax.com...
> Your problem is in SearchProgramHandle().  You don't show the code,
> but I'm guessing that you are using EnumWindows() to search, which
> might not work. (enumerates all windows on the screen, but hidden
> windows aren't on the screen, so...)
> You'll need to show your actual search code.
>
>
Technical Details
Message-ID: <3f91b0b3@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f90a515@newsgroups.borland.com> <srq1pvg3emp51jq97kjt2tkaqv8uoa5cpm@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,644d4ac8e2f18824
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-18 14:39:11 PST
From: "Martin C" <martinc@aol.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f90a515@newsgroups.borland.com> <srq1pvg3emp51jq97kjt2tkaqv8uoa5cpm@4ax.com>
Subject: Re: ShowWindow question
Date: Sat, 18 Oct 2003 13:29:24 -0800
Lines: 67
Organization: V Safe
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 81.10.4.238
Message-ID: <3f91b0b3@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1066512563 81.10.4.238 (18 Oct 2003 14:29:23 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail