如题

解决方案 »

  1.   

    我记得,前不久也有人在CSDN上提过这个问题。
    建议楼主查找一下。
      

  2.   

    給我點時間看能不能做出來, 可能不是很難, 
    找到 SysTabControl32, 然後....
      

  3.   

    在顶一下,
    期待 aiirii(ari) 大哥的杰作!
      

  4.   

    在网上找到一段代码, 能找出所有位置, 但, 还找不出标题, 我还要调试下!
    procedure TForm1.Button6Click(Sender: TObject);
    var
      r: TRect;
    begin
      r := GetTaskBarButtonRect1('Delphi 7 - Project1');
    end;function GetTaskBarButtonRect1(Title: string): TRect;
    const 
      MAX_TEXT = 256; 
    var
      h: HWND;
      C, i: integer;
      Item: tagTCITEM;
      Buff: PChar;
      S: array[0..255] of char;
      PID: THandle;
      PRC: THandle;
      R: Cardinal;
      pTxt: pointer;
    //  bRet: boolean;
    begin
      FillChar(Result, SizeOf(Result), 0);
      h := FindWindow('Shell_TrayWnd', nil);
      H := FindWindowEx(H, 0, 'ReBarWindow32', nil);
      H := FindWindowEx(H, 0, 'MSTaskSwWClass', nil);
      H := FindWindowEx(H, 0, 'SysTabControl32', nil);
      if H = 0 then Exit;
      GetWindowThreadProcessId(H, @PID);
      PRC := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or
        PROCESS_VM_WRITE, False, PID);
      if PRC = 0 then raise Exception.Create('Can''t Open Process');  pTxt := VirtualAllocEx(PRC, nil, MAX_TEXT, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE);
      Buff := VirtualAllocEx(PRC, nil, 4096, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE);
      if Buff = nil then raise Exception.Create('Can''t get Virtual Memory');
      try
        C := SendMessage(H, TCM_GETITEMCOUNT, 0, 0);
        for i := 0 to C - 1 do
        begin
          with Item do
          begin
            mask := TCIF_TEXT;
            dwState := 0;
            dwStateMask := 0;
            cchTextMax := MAX_TEXT - 1;
            pszText := pTxt;
            iImage := 0;
            lParam := 0;
          end;      /// Wish to get the Title string
          WriteProcessMemory(PRC, Buff, @Item, SizeOf(Item), R);
          SendMessage(H, TCM_GETITEM, i, Integer(Buff));      ReadProcessMemory(PRC, Buff, @Item, SizeOf(Item), R);
    //      if not bRet then raise Exception.Create('can''t Read Process Memory')
    //      else ShowMessage(intToStr(R) + ' -Size of item : ' + IntToStr(SizeOf(item)));
          ReadProcessMemory(PRC, PChar(pTxt), @s[0], SizeOf(S), R);
    //      ShowMessage(intToStr(R));
          /// But the S is NULL******
          ShowMessage(S);
          // if SameText(S, Title) then
          begin
            // we can get the RECT
            SendMessage(H, TCM_GETITEMRECT, i, integer(Buff));
            ReadProcessMemory(PRC, Buff, @Result, SizeOf(Result), R);        Windows.ClientToScreen(H, Result.TopLeft);
            Windows.ClientToScreen(H, Result.BottomRight);        Form1.Memo1.Lines.Add('current i is : ' + inttoStr(i));
            Form1.Memo1.Lines.Add(IntToStr(Result.Left));
            Form1.Memo1.Lines.Add(IntToStr(Result.Top));
            Form1.Memo1.Lines.Add(IntToStr(Result.Right));
            Form1.Memo1.Lines.Add(IntToStr(Result.Bottom));        // Break;
          end;
        end;  finally
        VirtualFreeEx(PRC, Buff, 0, MEM_RELEASE);
        VirtualFreeEx(PRC, pTxt, 0, MEM_RELEASE);
        CloseHandle(PRC);
      end;
    end;