Win32 datatypes are not needed, no need for uses windows.
They are not
required, no. But they do make things
easier and
consistent.
But, you
DO need to match the correct data type
sizes at least (ie
sizeof(WORD) <> sizeof(Int32)!), and especially the correct
calling convention (very important!), or else bad things
will happen, whether you notice them right away or not.
But the function works fine as is in a simple format.
It doesn't work correctly if you use the
wrong calling convention, for instance (as this example is doing).
If you compile for 32bit, then all Win32 APIs (except for
wsprintf(A/W)) use the
stdcall calling convention, NOT
cdecl, despite what MS's documentation suggests (since MS doesn't usually display the calling convention used, it is implied instead). So, don't mismatch them! In the example provided, stack corruption
WILL occur when the program tries to clean up the call stack a second time
AFTER MessageBoxTimeoutA() has
already cleaned up the call stack upon its exit.
If you compile for 64bit, then this issue is moot since there is only 1 calling convention defined by the Windows 64bit ABI, which the compiler handles for you, so the
cdecl/
stdcall keywords are ignored in code.