#include #include DWORD WINAPI ThreadFunc (LPVOID lpParam) { char szMsg[80]; sprintf (szMsg, "Parameter = %d.", *(DWORD *) lpParam); // MessageBox (NULL, szMsg, "ThreadFunc", MB_OK); pthread_cancel(pthread_self()); return 0; } int main (VOID) { DWORD dwThreadId, dwThrdParam = 1; HANDLE hThread; char szMsg[80]; hThread = CreateThread (NULL, // no security attributes 0, // use default stack size ThreadFunc, // thread function &dwThrdParam, // argument to thread function 0, // use default creation flags &dwThreadId); // returns the thread identifier // Check the return value for success. if (hThread == NULL) { wsprintf (szMsg, "CreateThread failed."); MessageBox (NULL, szMsg, "main", MB_OK); } else { sleep(2); CloseHandle (hThread); } }