Advertisement
WarPie90

Untitled

Jul 27th, 2016
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.78 KB | None | 0 0
  1. type
  2.   HWND = PtrUInt;
  3.   _EnumWindowsProc = function(wnd:HWND; Param: PtrUInt): LongBool;
  4.   TEnumWindowsProc = native(_EnumWindowsProc, ffi_stdcall);
  5.  
  6. function EnumWindows(lpEnumFunc: TEnumWindowsProc; Param: PtrUInt): LongBool; external 'EnumWindows@user32.dll stdcall';
  7. function GetWindowTextW(wnd: HWND; lpString: ^WideChar; nMaxCount: Int32): Int32; external 'GetWindowTextW@user32.dll stdcall';
  8.  
  9. function GetWindowText(wnd: HWND): WideString;
  10. type PWideChar = ^WideChar;
  11. begin
  12.   SetLength(Result, 1024);
  13.   SetLength(Result, GetWindowTextW(wnd, PWideChar(Result), 1024));
  14. end;
  15.  
  16.  
  17. procedure EnumProcesses();
  18.   function EnumProcess(Handle: HWND; Param: PtrUInt): LongBool; static;
  19.   begin
  20.     WriteLn GetWindowText(Handle);
  21.   end;
  22. begin
  23.   EnumWindows(@EnumProcess, 0);
  24. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement