GetClassName 显示乱码??????
[DllImport("user32.dll", CharSet = CharSet.Auto)]private static extern int GetClassName(IntPtr
hWnd, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder
ClassName, int nMaxCount);
Process p = Process.GetCurrentProcess();
StringBuilder windowname = new StringBuilder(256);
p.WaitForInputIdle();
IntPtr hWnd = p.MainWindowHandle;
while (!p.HasExited)
{
p.Refresh();
if (p.MainWindowHandle.ToInt32() != 0)
{
hWnd = p.MainWindowHandle;
break;
}
}
GetClassName(hWnd, windowname, windowname.Capacity);
windowname显示结果为"{WindowsForms10.Window.8.app.0.bf7d44_r28_ad1} "
我想要的结果是"Form1".求解. --------------------编程问答-------------------- 不乱,运行时就是这个,你用spy++看就知道了 --------------------编程问答-------------------- 此class非彼class
建议楼主了解一下基本的win32程序 --------------------编程问答-------------------- 这就是正常的classname哦 --------------------编程问答--------------------
那在知道句柄的情况下,怎样获得类名或者抓到窗口的实例对象? --------------------编程问答-------------------- formhandler
补充:.NET技术 , C#