我正在尝试从另一个应用程序的状态栏的一部分获取文本。我可以获取句柄 OK,我只是无法从我的 stringbuilder 获取文本,当在消息框中显示时,它什么也不显示。
到目前为止的代码
[DllImport("user32.dll")]
static extern int SendMessage(IntPtr hwnd, int message, int wParam, [MarshalAs(UnmanagedType.LPStr)] StringBuilder lParam);
[DllImport("user32.dll")]
static extern int SendMessage(IntPtr hwnd, int message, int wParam, int lParam);
IntPtr statbarhandle = IntPtr.Zero;
StringBuilder sbb = new StringBuilder(50);
StringBuilder classname = new StringBuilder(20);
classname.Append("msctls_statusbar32");
statbarhandle = FindWindowEx(gr3hwnd, IntPtr.Zero, classname, null);
int numofparts = SendMessage(statbarhandle, 0x406, 0, 0);
SendMessage(statbarhandle, 0x402, 3, sbb);
MessageBox.Show(sbb.ToString());
顺便说一句,SB_GETPARTS 工作得很好。谁能帮帮我?
我是一名优秀的程序员,十分优秀!