You need not to change the signature / name of the DLL that you refer to when calling the USER32.DLL functions.
Despite the naming convention, on a 64-bit Windows machine, the USER32.DLL file, which is located in [Windows] \ System32, is actually a 64-bit DLL. The true 32-bit version of USER32.DLL is actually located in a folder named [Windows] \ SysWow64.
See this question for more details.
The only thing you probably have to pay special attention to is the data types that you pass as parameters for various Windows API functions. For example, the "SendMessage" function in USER32.DLL has a specific requirement with at least one of its parameters (according to the P / Invoke page ).
Signature:
[DllImport("user32.dll", CharSet = CharSet.Auto)] static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
and notes 2 and 3 below clearly state:
2) NEVER use "int" or "integer" as LPARAM. Your code will be broken into 64-bit windows. ONLY use IntPtr, a "ref" structure, or an "outside" structure.
3) NEVER use "bool", "int" or "integer" as the return value. Your core WILL will split into 64-bit windows. ONLY use IntPtr. Using bool is unsafe - pInvoke cannot IntPtr for booleans.
This “disclaimer” seems to be specific to this particular function (SendMessage), although I would pay special attention when calling any Windows API functions.
Craigtp
source share