Żub*_*wka 6 c# 64-bit pinvoke winapi 32-bit
我正在使用以下代码:
const int GWL_STYLE = (-16);
const UInt32 WS_POPUP = 0x80000000;
const UInt32 WS_CHILD = 0x40000000;
[DllImport("user32.dll", SetLastError = true)]
static extern UInt32 GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, UInt32 dwNewLong);
Run Code Online (Sandbox Code Playgroud)
在某个地方......
SetWindowLong(this.Handle, GWL_STYLE,
((GetWindowLong(this.Handle, GWL_STYLE) & ~(WS_POPUP)) | WS_CHILD));
Run Code Online (Sandbox Code Playgroud)
这会在32位和64位机器上正常运行吗?
如果没有,如果我编译我的应用程序作为x86进程运行,它仍然可以在64位计算机上正常工作吗?
如何在32位和64位计算机上重写以下代码?
我想你想知道你是否正确选择了UInt32类型.答案是肯定的.文档明确表示它总是32位值:http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v = vs.85).aspx
你的代码是正确的.