Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi-HWND到列表框_Delphi - Fatal编程技术网

Delphi-HWND到列表框

Delphi-HWND到列表框,delphi,Delphi,我想从另一个窗口读取文本,并将其放在我表格的列表框中 看到下面的代码,我得到了文本的房间类别,但我不知道如何隐藏它 到列表框 procedure TForm1.GetNicksBtnClick(Sender: TObject); var hWnd1 :long; CheckMsg :String; begin CheckMsg := '1'; //convert it to 0 to you can check the FindWindowEx hWnd1 := FindWin

我想从另一个窗口读取文本,并将其放在我表格的列表框中

看到下面的代码,我得到了文本的房间类别,但我不知道如何隐藏它 到列表框

procedure TForm1.GetNicksBtnClick(Sender: TObject);
var
  hWnd1 :long;
  CheckMsg :String;
begin
  CheckMsg := '1'; //convert it to 0 to you can check the FindWindowEx

  hWnd1 := FindWindow('DlgGroupChat Window Class',Pchar(cbPalWindows.Text));
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('1');
  Exit;

   hWnd1 := FindWindowEx(hWnd1,0,'SplitterWindowEx',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('2');
  Exit;

  hWnd1 := FindWindowEx(hWnd1,0,'SplitterWindowEx',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('3');
  Exit;

  hWnd1 := FindWindowEx(hWnd1,0,'SplitterWindowEx',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('4');
  Exit;

  hWnd1 := FindWindowEx(hWnd1,0,'SplitterWindowEx',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('5');
  Exit;

  hWnd1 := FindWindowEx(hWnd1,0,'SplitterWindowEx',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('6');
  Exit;

  hWnd1 := FindWindowEx(hWnd1,0,'ClassCPaneContainerEx',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('7');
  Exit;

  hWnd1 := FindWindowEx(hWnd1,0,'ATL:00AD6100',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('8');
  Exit;

  hWnd1 := FindWindowEx(hWnd1,0,'ATL:00AD65E0',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('9');
  Exit;

  hWnd1 := FindWindowEx(hWnd1,0,'AtlAxWin90',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('10');
  Exit;

  hWnd1 := FindWindowEx(hWnd1,0,'#32770',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('11');
  Exit;

  hWnd1 := FindWindowEx(hWnd1,0,'RichEdit20W',nil);
  if (hWnd1 = 0) and (CheckMsg = '0') then //for test purposes
  showmessage('12');
  Exit;

  if hWnd1 <> 0 then
  Begin
  End;

end;
procedure TForm1.GetNicksBtnClick(发送方:TObject);
变量
hWnd1:长;
CheckMsg:String;
开始
CheckMsg:=“1”//将其转换为0,以便您可以检查FindWindowEx
hWnd1:=FindWindow('DlgGroupChat窗口类',Pchar(cbPalWindows.Text));
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('1');
出口
hWnd1:=FindWindowEx(hWnd1,0,'SplitterWindowEx',nil);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('2');
出口
hWnd1:=FindWindowEx(hWnd1,0,'SplitterWindowEx',nil);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('3');
出口
hWnd1:=FindWindowEx(hWnd1,0,'SplitterWindowEx',nil);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('4');
出口
hWnd1:=FindWindowEx(hWnd1,0,'SplitterWindowEx',nil);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('5');
出口
hWnd1:=FindWindowEx(hWnd1,0,'SplitterWindowEx',nil);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('6');
出口
hWnd1:=FindWindowEx(hWnd1,0,'ClassCPaneContainerEx',nil);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('7');
出口
hWnd1:=FindWindowEx(hWnd1,0,'ATL:00AD6100',无);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('8');
出口
hWnd1:=FindWindowEx(hWnd1,0,'ATL:00AD65E0',无);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('9');
出口
hWnd1:=FindWindowEx(hWnd1,0,'AtlAxWin90',nil);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('10');
出口
hWnd1:=FindWindowEx(hWnd1,0,#32770',无);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('11');
出口
hWnd1:=FindWindowEx(hWnd1,0,'RichEdit20W',nil);
如果(hWnd1=0)和(CheckMsg='0'),则//用于测试目的
showmessage('12');
出口
如果hWnd1为0,则
开始
结束;
结束;
这是VB上写的代码,我怎么能在delphi上做呢

Dim i As Integer
Dim iHnd8 As Long
If iHnd8 <> IntPtr.Zero Then
Dim NicArray() As String = mdlSysListView.GetAllSLVItems(iHnd8)
Debug.Print(NicArray.Length.ToString)
For i = 0 To NicArray.Length - 1
ListBox1.Items.Add(NicArray(i))
Next
ListBox1.Items.Insert(0, "Total # of Nics in room is - " & ListBox1.Items.Count)
End If
Dim i作为整数
暗iHnd8与长
如果iHnd8 IntPtr.为零,则
Dim NicArray()作为字符串=mdlSysListView.GetAllsVitems(iHnd8)
Debug.Print(NicArray.Length.ToString)
对于i=0到NicArray.Length-1
列表框1.Items.Add(NicArray(i))
下一个
ListBox1.Items.Insert(0,“房间中NIC的总数为-”&ListBox1.Items.Count)
如果结束

您正试图在另一个进程中读取列表视图控件的内容。这并不简单,因为它涉及LVM_GETITEMTEXT消息,它要求您传递一个指向目标进程地址空间中分配的内存的指针

为了满足该要求,您需要执行以下操作:

  • 查找目标进程的进程ID
  • 调用OpenProcess以获取进程句柄
  • 调用VirtualAllocEx为另一个进程中的LVITEM结构分配内存
  • 使用WriteProcessMemory初始化结构
  • 向控件发送LVM_GETITEMTEXT消息
  • 使用ReadProcessMemory读取结构的内容 这是一个相当棘手的问题,需要您非常清楚地了解Win32编程的许多不同方面

    规范教程如下所示:


    现在,在VB和Delphi中,更好的方法是使用自动化API,假设目标应用程序支持此功能

    你的代码实际上什么都不做。它尝试获取“DlgGroupChat窗口类”窗口的句柄并退出该方法。我想这是,为了完整起见,这里是方法。祝你好运@TLama-因此OP真正的问题是,'如何将这个自定义VB.NET例程(
    GetAllsVitems
    )翻译成Delphi Pascal'?@Chris,我会说是的,因为Delphi code.OP中没有太多可添加到列表框中的内容-假设@TLama是正确的,我认为你应该接受David Heffernan的答案,开始一个新的问题,用你正在努力翻译的
    GetAllsVitems
    (它或多或少直接翻译,不过也可以稍微清理一下)。