Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.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
C# 使用EnumChildWindows确定IntPtr实例的位数_C#_.net_Winapi_32bit 64bit_Intptr - Fatal编程技术网

C# 使用EnumChildWindows确定IntPtr实例的位数

C# 使用EnumChildWindows确定IntPtr实例的位数,c#,.net,winapi,32bit-64bit,intptr,C#,.net,Winapi,32bit 64bit,Intptr,我发布了一个类似的问题,但决定重新发布,关注部分问题 我正在从32位WinForms应用程序在64位windows 7上使用EnumWindows和EnumChildWindows枚举窗口。声明如下: public delegate int EnumWindowsCallback (System.IntPtr hWnd, System.IntPtr lParam); [DllImport("user32.Dll")] public static extern bool EnumWindows

我发布了一个类似的问题,但决定重新发布,关注部分问题

我正在从32位WinForms应用程序在64位windows 7上使用EnumWindows和EnumChildWindows枚举窗口。声明如下:

public delegate int EnumWindowsCallback (System.IntPtr hWnd, System.IntPtr lParam);

[DllImport("user32.Dll")]
public static extern bool EnumWindows (EnumWindowsCallback lpEnumCallbackFunc, IntPtr lParam);

[DllImport("user32")]
public static extern bool EnumChildWindows (IntPtr hWnd, EnumWindowsCallback lpEnumCallbackFunc, IntPtr lParam);
我将
[Process.getprocesss()[I].MainWindowHandle]
作为参数发送到
[EnumWindows]
以枚举所有进程的所有子窗口

调用
[EnumChildWindows]
时,
[hWnd]
参数可以是在32位或64位进程中运行的窗口的句柄。由于我的应用程序是32位的,我如何判断是调用
[hWnd.ToInt32()]
还是
[hWnd.ToInt64()]
。我需要调用这两个函数中的一个来比较IntPtr


上下文:Windows 7(64位),VS 2010,WinForms(32位)。

您不需要做任何特殊的事情,
hwnd
不是指针,而是句柄,对于这种类型的64位,只有较低的32位是有效的,因此它们可以自由共享

终于!感谢您的回答和MSDN链接。干杯