挖井

类库大魔王的挖井日记

挖一口属于自己的井


编程读取其它进程中ToolBar的内容

void __fastcall TMainForm::GetToolBarContent()
{
        //TODO: Add your source code here
    int nItemCount;
    int i;
    char chBuffer[256];
    DWORD dwProcessID;
    HANDLE hProcess;
    void * Pointer;
    SIZE_T nNumberOfBytesRead;
   
    nItemCount = SendMessage(hWindow, TB_BUTTONCOUNT, 0, 0);
    GetWindowThreadProcessId(hWindow, &dwProcessID);
    hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE,
                    false,
                    dwProcessID);
    Pointer = VirtualAllocEx(hProcess,
                            NULL,
                            4096,
                            MEM_RESERVE | MEM_COMMIT,
                            PAGE_READWRITE);
    try{
    for(i= 0 ; i < nItemCount ; ++i)
    {                        
       TBBUTTON bi;
       SendMessage(hWindow, TB_GETBUTTON, i, (LPARAM)Pointer);
       ReadProcessMemory(hProcess,
                        (Pointer),
                        &bi,
                        sizeof(bi),
                        &nNumberOfBytesRead);
       SendMessage(hWindow, TB_GETBUTTONTEXT , bi.idCommand, (LPARAM)(Pointer));
       ReadProcessMemory(hProcess,
                    (void *)(Pointer),
                    chBuffer,
                    sizeof(chBuffer),
                    &nNumberOfBytesRead);
       ContentMemo->Lines->Add(chBuffer);
    }//for(i...
    }//try
    __finally
    {
      VirtualFreeEx(hProcess,
                    Pointer,
                    0,
                    MEM_RELEASE);
      CloseHandle(hProcess);
    }
}

本文地址:

https://minidump.info/blog/2005/02/E7-BC-96-E7-A8-8B-E8-AF-BB-E5-8F-96-E5-85-B6-E5-AE-83-E8-BF-9B-E7-A8-8B-E4-B8-ADToolBar-E7-9A-84-E5-86-85-E5-AE-B9/

上一篇

编程读取其它进程中TabControl的内容

void __fastcall TMainForm::GetTabControlContent(){ //TODO: Add your source code here int nItemCount; int i; char chBuffer[256]; ...…

imported from CSDN 全文阅读
下一篇

编程读取其它进程中TreeView的内容

void __fastcall TMainForm::GetTreeViewContent(){ //TODO: Add your source code here int nItemCount; int i; char chBuffer[256]; DW...…

imported from CSDN 全文阅读