function GetTridentCmboBxText( // 获取其他进程中“Internet Explorer_TridentCmboBx”的内容 mHandle: THandle; // ComboBox句柄 mStrings: TStrings // 输出列表 ): Boolean; // 返回获取数据是否成功 var I: Integer; vItemCount: Integer; vAddress: array[0..4] of Char; vProcessID: THandle; vProcess: THandle; vNumberOfBytesRead: DWORD; W: WideString; begin //设计 Zswang 2006-09-12 wjhu111#21cn.com 尊重作者,转贴请注明出处 Result := False; if not Assigned(mStrings) then Exit; GetWindowThreadProcessId(mHandle, vProcessID); SetLength(W, 256); mStrings.BeginUpdate; vProcess := OpenProcess(PROCESS_VM_READ, False, vProcessID); try mStrings.Clear; vItemCount := SendMessage(mHandle, CB_GETCOUNT, 0, 0); for I := 0 to vItemCount - 1 do begin FillChar(vAddress, SizeOf(vAddress), 0); SendMessage(mHandle, CB_GETLBTEXT, I, Integer(@vAddress)); ReadProcessMemory(vProcess, Pointer(PInteger(@vAddress)^), @W[1], 512, vNumberOfBytesRead); mStrings.Add(W); end; SetLength(W, 0); finally mStrings.EndUpdate; end; Result := True; end; { GetTridentCmboBxText }
http://blog.csdn.net/zswang/article/details/1214827