好的,首先,我是C语言的新手,所以这可能很简单,我只是在Google/so中找不到答案。
我有一个试图使用FindWindowEx的类,但是Visual Studio不允许我使用“null”参数,我不确定为什么。
到目前为止,该类具有以下代码:
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr handleParent, IntPtr handleChild, string className, string WindowName);
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
public void SomeWindow()
{
String someHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "SomeWindowClass", NULL);
}
正如所写的,它告诉我“NULL”在当前上下文中不存在。我也尝试过这样写:
FindWindowEx(null, null, "SomeWindowClass", null)
这会在前两个“null”表示“Argument#:无法从“null”转换为“IntPtr”时出现错误(“null”实际上有<和>围绕着它,尽管它没有显示出来)
Windows开发中心表示,我应该能够按自己的想法使用它,如下所示:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633500(v=vs.85).aspx
就像我说的,这可能非常简单,我只是没有足够的C语言经验来理解它。