user256890
user256890

Reputation: 3424

P/Invoke on 32 bit and 64 bit systems

Let us pick the following Win API call as an example:

BOOL MessageBeep(UINT uType); // from User32.dll

The input parameter is UINT to specify the beep type, which is can be both 32bit and 64bit integer, depending on which Windows version we call it on (or am I wrong?).

If I want to P/Invoke message beep from C#, so I apply the DllImport declaration:

[DllImport("User32.dll")]
static extern Boolean MessageBeep(UInt32 beepType);

Will this code C# work under Windows x64?

Upvotes: 2

Views: 2323

Answers (1)

SLaks
SLaks

Reputation: 887509

You are wrong.

However, for types like HANDLE that do vary with bitness, you should use IntPtr.

If you're uncertain about a P/Inoke declaration, the first place to check is here.

Upvotes: 5

Related Questions