Einzelnen Beitrag anzeigen

Razor
(Gast)

n/a Beiträge
 
#4

Re: Create Sys Tray / Capture

  Alt 2. Jul 2009, 15:47
Ok i finally managed to do something..I can get Number of tray icons + tooltips however no icons or no mouse interactivity yet.So i hope you guys can help on that one.Ive done my part now i expect from you to do the same.

This works on WINDOWS 7264 RTM Build!

Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,shellAPI, ComCtrls, ImgList,commctrl, ExtCtrls;

type
  TForm2 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;
    h_Tray:hwnd;

function GetSysTrayWnd: HWND;
begin
  Result := FindWindow('Shell_TrayWnd', nil);
  Result := FindWindowEx(Result, 0, 'TrayNotifyWnd', nil);
  Result := FindWindowEx(Result, 0, 'SysPager', nil);
  Result := FindWindowEx(Result, 0, 'ToolbarWindow32', nil);
end;

procedure TForm2.Button1Click(Sender: TObject);
var
  h_ico: HICON;
  h_icolist: TStringlist;
  btn_count, i,handleicon: integer;
  h_Process, dwProcessID:DWord;
  Point: Pointer;
  btn_ico: TTBButton;
  nNumberOfBytesRead: dword;
  buffer: array[0..255] of Char;
begin
  h_Tray:=GetSysTrayWnd;
  btn_count:=sendmessage(h_Tray,TB_BUTTONCOUNT,0,0);
  GetWindowThreadProcessId(h_Tray,@dwProcessID);
  h_Process:=OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or PROCESS_VM_WRITE,
                        false,
                        dwProcessID);
  point:=VirtualAllocEx(h_Process, nil,
                        4096,
                        MEM_RESERVE or MEM_COMMIT,
                        PAGE_READWRITE);
  for i:=0 to btn_count - 1 do
  begin
    SendMessage(h_Tray, TB_GETBUTTON, i, LPARAM(Point));
    ReadProcessMemory(h_Process,
                      (Point),
                      @btn_ico,
                      sizeof(btn_ico),
                      nNumberOfBytesRead);
    SendMessage(h_Tray, TB_GETBUTTONTEXT , i, LPARAM(Point));
    ReadProcessMemory(h_Process,
                      (Point),
                      @buffer,
                      sizeof(buffer),
                      nNumberOfBytesRead);
    listbox1.Items.Add(buffer);

  end;

  SHOWmessage(inttostr(btn_count));
  handleicon:=SendMessage(h_Tray,TB_GETIMAGELIST,0,0);
  ImageList_GetIcon(handleicon,0,0); ///????
  image1.Canvas.Handle:=ImageList_GetIcon(handleicon,1,0); ///????
Miniaturansicht angehängter Grafiken
untitled_208.png  
  Mit Zitat antworten Zitat