Einzelnen Beitrag anzeigen

simjoh

Registriert seit: 13. Nov 2006
Ort: Asslar
99 Beiträge
 
Delphi 7 Enterprise
 
#13

Re: GetDC, Canvas, bsclear

  Alt 13. Jul 2007, 08:45
Hi, sorry, bin gestern gleich offline gegangen, hätt ich gewusst, dass ich noch ne Antwort bekomme, wäre ich noch wach geblieben. Das Handle ermittle ich im Prinzip so:

Delphi-Quellcode:
//fill in the listview with all the information
procedure TMainForm.WriteText(Wnd: HWnd);
var pcWinText : PChar;
    NewItem : TListItem;
    aProcessEntry32 : TProcessEntry32;
    aSnapshotHandle : THandle;
    WinVersion : DWord;
    ProcessID : longint;
    ContinueLoop : boolean;
begin
  NewItem:=ListView.Items.Add;
  {Is Window Visible?}
  NewItem.Checked:=IsWindowVisible(wnd);
  {WindowCaption}
  pcWinText:= StrAlloc(102);
  GetWindowText(Wnd, pcWinText, 100);
  NewItem.Caption:=StrPas(pcWinText);
  StrDispose(pcWinText);
  {WindowClassName}
  pcWinText:= StrAlloc(102);
  GetClassName(Wnd, pcWinText, 100);
  NewItem.SubItems.Add(StrPas(pcWinText));
  StrDispose(pcWinText);
  {WindowHandle}
  NewItem.SubItems.Add(IntToHex(wnd, 8));
  {WindowThreadProcessID}
  GetWindowThreadProcessID(wnd,@ProcessID);
  NewItem.SubItems.Add(IntToHex(ProcessID, 8));
  {WindowsVersion}
  WinVersion:=GetProcessVersion(ProcessID);
  NewItem.SubItems.Add(IntToStr(WinVersion shr 16)+'.'+IntToStr(WinVersion mod $1000));
  {CommandLine}
  {According to Christian Kästner:}
  aSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
  aProcessEntry32.dwSize := Sizeof(aProcessEntry32);
  ContinueLoop := Process32First(aSnapshotHandle, aProcessEntry32);
  while integer(ContinueLoop) <> 0 do begin
    if aProcessEntry32.th32ProcessID = ProcessID then
      NewItem.SubItems.Add(ExtractFileName(aProcessEntry32.szExeFile));
    ContinueLoop := Process32Next(aSnapshotHandle,aProcessEntry32);
  end;
  CloseHandle(aSnapshotHandle);
  {end of Chrstian's stuff}
end;
Gruß
  Mit Zitat antworten Zitat