VC in the Win32 console program, and then contains the MFC program, with CreateThread () to its corresponding function of the problem of parameters
test.cpp : Defines the entry point for the console application.//#include "stdafx.h" #include "test.h" #ifdef _debug#define new debug_new# undef this_filestatic char this_file[] = __file__; #endif///////////////////////////// The one and only application objectcwinapp theapp;using namespace std;static int count=5;static handle H1=NULL;STATIC HANDLE H2;DWORD DWFUN;INT FUNC1 (int *a); Void func2 (); int _ Tmain (int argc, tchar* argv[], tchar* envp[]) { int nretcode = 0; h1=createthread (lpsecurity_attributes) null, // default security attribute pointer 0, // Thread stack size (lpthread_start_routine) func1, /Functions to be executed by the/ thread (LPVOID) &count, // parameters to be passed by the thread corresponding function 0, // the state at which the thread was created, 0 means immediate execution, and if create_suspended is pending after creation, ResumeThread () is required to execute &dwfun); // thread identifier pointer sleep ( closehandle (FUNC1); exitthread (0); return nretcode;} Note that the arguments in the function must use the pointer type, because LPVOID is a pointer type and is used in a function with the pointer reference int func1 (INT *A) { printf ("This is a running thread!\n%d\n ", 2**a); return 0;}
VC6.0 problems with threads created in the