AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Hilfe beim Übersetzten von C in Delphi

Ein Thema von simjoh · begonnen am 23. Mär 2007 · letzter Beitrag vom 1. Apr 2007
 
simjoh

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

Re: Hilfe beim Übersetzten von C in Delphi

  Alt 27. Mär 2007, 18:26
So, vielleicht keine Erhellung für alle, aber immerhin:

Delphi-Quellcode:
unit UnitPHG;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,{ ShellAPI,} TLHelp32;

type
  TForm1 = class(TForm)
    Button1: TButton;
    PLiveTicker: TPanel;
    PPartyWindowProcessID: TPanel;
    Label1: TLabel;
    PPartyWindowClassName: TPanel;
    PPartyWindowHandle: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    Panel1: TPanel;
    Label4: TLabel;
    PPartyWindowExe: TPanel;
    Label5: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
    WM_ENUMERATE_ID: integer;
  public
    { Public-Deklarationen }
    procedure WriteText(Wnd: HWnd);
    procedure WndProc(var Message: TMessage); override;
  end;

var
  Form1: TForm1;



// get a messageID from Windows
function RegisterMessage: integer;

// this is the callbackfunction. Don't miss stdcall
// can't be part of the form.
function EnumWinProc(Wnd: HWnd; param: lParam): boolean; stdcall;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  // get our msgID
  WM_ENUMERATE_ID:= RegisterMessage;
end;

function RegisterMessage: integer;
begin
  Result:= RegisterWindowMessage('Enumerate this Window');
end;

function EnumWinProc(Wnd: HWnd; param: lParam): boolean; stdcall;
var iMsgID: integer;
begin
  iMsgID:= RegisterMessage;
  // give data to main form
  SendMessage(param, iMsgID, 0, Wnd);

  Result:=true;
end;

procedure TForm1.WndProc(var Message: TMessage);
begin
  if Message.Msg=WM_ENUMERATE_ID then
    // oh! Enumerate Window found a window, lets do something
    WriteText(Message.lParam)
  else
    inherited WndProc(Message);
end;

//fill in the listview with all the information
procedure TForm1.WriteText(Wnd: HWnd);
var pcWinText : PChar;
    Str: string;
    aProcessEntry32 : TProcessEntry32;
    aSnapshotHandle : THandle;
    WinVersion : DWord;
    ProcessID : longint;
    ContinueLoop : boolean;
begin
  {WindowCaption ermitteln}
  pcWinText:= StrAlloc(102);
  GetWindowText(Wnd, pcWinText, 100);
  if Pos('PartyPoker.com:',StrPas(pcWinText))<>0 then
  begin
    Panel1.Caption:=StrPas(pcWinText);
    StrDispose(pcWinText);
    {WindowClassName ermitteln}
    pcWinText:= StrAlloc(102);
    GetClassName(Wnd, pcWinText, 100);
    PPartyWindowClassName.Caption :=StrPas(pcWinText);
    StrDispose(pcWinText);
    {WindowHandle ermitteln}
    PPartyWindowHandle.Caption :=IntToHex(wnd, 8);
    {WindowThreadProcessID}
    GetWindowThreadProcessID(wnd,@ProcessID);
    PPartyWindowProcessID.Caption:=IntToHex(ProcessID, 8);

    {Weiter: Speicher auslesen: GetMemoryList(ProcessID);}

  end;
  {According to Christian Kästner: Bestimmt die exe-Datei}
  aSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
  aProcessEntry32.dwSize := Sizeof(aProcessEntry32);
  ContinueLoop := Process32First(aSnapshotHandle, aProcessEntry32);
  while integer(ContinueLoop) <> 0 do begin
    if aProcessEntry32.th32ProcessID = ProcessID then
      PPartyWindowExe.Caption:=(ExtractFileName(aProcessEntry32.szExeFile));
    ContinueLoop := Process32Next(aSnapshotHandle,aProcessEntry32);
  end;
  CloseHandle(aSnapshotHandle);
  {end of Chrstian's stuff}
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  // start EnumerateWindows, send the Handle of the Form
  // so function nows where to send the info
  EnumWindows(@EnumWinProc, self.Handle);
end;

end.
Wie der Speicher jetzt ausgelesen wird, weiß ich noch nicht.
  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 08:25 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