You're using managed C++ (C++/CLR). This is very different from native C++ (which the tutorial was written for).
In managed C++, the default calling convention is not compatible with the calling convention of the function pointer that the native _beginthread
function is expecting. Fortunately, managed C++ has very good interop with native C++, and changing your function declaration to the following should work:
void __cdecl Test( void *arg )
Since you're using managed C++, you have the full power of .NET on your side, and could instead create managed threads (e.g. with a Task
object).
Note also that any win32 UI object created on the main thread must only be accessed on that thread -- so be careful! :-)