您现在的位置:首页 >> API >> API >> 内容

Delphi如何遍历任务栏上的窗体

时间:2011/9/3 14:53:58 点击:

  核心提示:uses CommCtrl;procedure TForm1.Button1Click(Sender: TObject);varvHandle: THandle;vCount: Integer;I:...
uses CommCtrl;   procedure TForm1.Button1Click(Sender: TObject); var  vHandle: THandle;  vCount: Integer;  I: Integer;  vProcessID: THandle;  vProcess: THandle;  vNumberOfBytesRead: DWORD;  vPointer: Pointer;  vBuffer: array[0..255] of Char; begin  vHandle := FindWindow('Shell_TrayWnd', nil);  vHandle := FindWindowEx(vHandle,0,'ReBarWindow32', nil);  vHandle := FindWindowEx(vHandle,0,'MSTaskSwWClass', nil);  vHandle := FindWindowEx(vHandle,0,'ToolbarWindow32', nil);  vCount := SendMessage(vHandle, TB_BUTTONCOUNT,0,0);  GetWindowThreadProcessId(vHandle,@vProcessId);  vProcess := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or     PROCESS_VM_WRITE, False, vProcessId);  vPointer := VirtualAllocEx(vProcess, nil,$1000, MEM_RESERVE or MEM_COMMIT,     PAGE_READWRITE);  try     for I :=0 to vCount -1 do     begin       SendMessage(vHandle, TB_GETBUTTONTEXT, I, Integer(vPointer));       ReadProcessMemory(vProcess, vPointer,@vBuffer,         SizeOf(vBuffer), vNumberOfBytesRead);       OutputDebugString(@vBuffer);     end;  finally     VirtualFreeEx(vProcess, vPointer,0, MEM_RELEASE);     CloseHandle(vProcess);  end; end;

作者:王集鹄 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
本类推荐
  • 没有
本类固顶
  • 没有
  • 盒子文章(www.2ccc.com) © 2022 版权所有 All Rights Reserved.
  • 沪ICP备05001939号