AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Handle eines Fensters über die Processid?
Thema durchsuchen
Ansicht
Themen-Optionen

Handle eines Fensters über die Processid?

Ein Thema von gandime · begonnen am 26. Jul 2007 · letzter Beitrag vom 26. Jul 2007
 
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#8

Re: Handle eines Fensters über die Processid?

  Alt 26. Jul 2007, 13:53
So geht es:
Delphi-Quellcode:
function EnumWindowsProc(hWnd: THandle; lp: LPARAM): LongBool; stdcall;
var
  ID : DWORD;
  len : Integer;
  Caption : PChar;
begin
  if IsWindow(hWnd) and IsWindowVisible(hWnd) then
  begin
    GetWindowThreadProcessId(hWnd, ID);
    if GetCurrentProcessId = ID then
    begin
      len := SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0);
      Caption := GetMemory(len + 1);
      try
        SendMessage(hWnd, WM_GETTEXT, len, Integer(Caption));
        MessageBox(0, Caption, 'Test', 0);
      finally
        Freememory(Caption);
      end;
    end;
  end;
  Result := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  EnumWindows(@EnumWindowsProc, 0);
end;
GetWindowThreadID gibt nicht die ProzesID als Funktionsrückgabewert zurück, sondern im zweiten Parameter. Und wieder hilft es die Hilfe zu lesen:
Zitat:
Code:
hWnd
[in] Handle to the window.
lpdwProcessId
[out] Pointer to a variable that receives the process identifier. If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the variable; otherwise, it does not.
Und
Zitat:
Code:
Return Value

The return value is the identifier of the thread that created the window.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz