This is what I've always written by hand for AnyCPU builds (which is all builds, due to the viral nature of using anything other than AnyCPU being a headache):
[DllImport("user32.dll", EntryPoint="GetWindowLong", SetLastError=true)]
private static extern int GetWindowLong_x86(IntPtr hWnd, GWL nIndex);
[DllImport("user32.dll", EntryPoint="GetWindowLongPtr", SetLastError=true)]
private static extern IntPtr GetWindowLongPtrImpl_x64(IntPtr hWnd, GWL nIndex);
public static IntPtr GetWindowLongPtr(IntPtr hWnd, GWL nIndex)
{
return IntPtr.Size == 4 ? (IntPtr)GetWindowLong_x86(hWnd, nIndex) : GetWindowLongPtrImpl_x64(hWnd, nIndex);
}
[DllImport("user32.dll", EntryPoint="SetWindowLong", SetLastError=true)]
private static extern int SetWindowLong_x86(IntPtr hWnd, GWL nIndex, int dwNewLong);
[DllImport("user32.dll", EntryPoint="SetWindowLongPtr", SetLastError=true)]
private static extern IntPtr SetWindowLongPtr_x64(IntPtr hWnd, GWL nIndex, IntPtr dwNewLong);
public static IntPtr SetWindowLongPtr(IntPtr hWnd, GWL nIndex, IntPtr dwNewLong)
{
return IntPtr.Size == 4 ? (IntPtr)SetWindowLong_x86(hWnd, nIndex, (int)dwNewLong) : SetWindowLongPtr_x64(hWnd, nIndex, dwNewLong);
}
Could CsWin32 conceivably generate equivalent methods that dispatch at runtime based on architecture when the project is AnyCPU, a necessity for AnyCPU assemblies?
This is what I've always written by hand for AnyCPU builds (which is all builds, due to the viral nature of using anything other than AnyCPU being a headache):
Could CsWin32 conceivably generate equivalent methods that dispatch at runtime based on architecture when the project is AnyCPU, a necessity for AnyCPU assemblies?