Показать сообщение отдельно
  #12  
Старый 22.09.2011, 07:56
Pyro Pyro вне форума
Так проходящий
 
Регистрация: 18.07.2011
Сообщения: 805
Версия Delphi: 7Lite
Репутация: 6063
По умолчанию

поиск по части заголовка и имени exe:
FindWindow777('opera') ;
FindWindow777('torrent', 'utorrent.exe') ;

PHP код:
uses psapi;
var
  
FoundHandleCardinal;
  
Matchstring;
  
exetofindstring;
function 
FindWindow777(TitlePartstringexenamestring ''): Cardinal;
  function 
Enumka(hhWndpPointer): BOOLstdcall; var s1s2string;
    function 
GetModule(hhWnd): string;
    var
      
Modulestring;
      
shit1Cardinal;

      function 
ProcessFileName(PIDDWORD): string;
      var
        
HandleTHandle;
      
begin
        Result 
:= '';
        
Handle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READFalsePID);
        if 
Handle <> 0 then
          
try
            
SetLength(ResultMAX_PATH);
            
begin
              
if GetModuleFileNameEx(Handle0PChar(Result), MAX_PATH) > 0 then
                SetLength
(ResultStrLen(PChar(Result)))
              else
                
Result := '';
            
end
          finally
            CloseHandle
(Handle);
          
end;
      
end;
    
begin
      GetWindowThreadProcessId
(hshit1);
      
result := ProcessFileName(shit1);
    
end;
    function 
GetCaption(hhWnd): string;
    var
      
Caption: array[0..255of char;
    
begin
      FillChar
(Captionsizeof(Caption), 0);
      
GetWindowText(hCaption255);
      
result := strpas(Caption);
    
end;

  
begin
    result 
:= true;
    if 
Pos(LowerCase(Match), LowerCase(GetCaption(h))) > 0 then
      
if exetofind '' then
      begin
        FoundHandle 
:= h;
        
result := false;
      
end else {begin
       s1 
:= GetModule(h);
       
s2 := GetCaption(h) ;  }
      if 
exetofind ExtractFileName(GetModule(h)) then
      begin
        FoundHandle 
:= h;
        
result := false;
      
end;  {end; }
  
end;
begin
  exetofind 
:= exename;
  
FoundHandle := INVALID_HANDLE_VALUE;
  
Match := TitlePart;
  
EnumWindows(@Enumka0);
  
result := FoundHandle;
end
Ответить с цитированием