#include <windows.h> typedef struct tagTHREADSTRUCT { int n; LPTSTR s; } THREADSTRUCT, *LPTHREADSTRUCT; DWORD WINAPI ThreadProc(LPVOID lpParameter) { LPTHREADSTRUCT ts = (LPTHREADSTRUCT)lpParameter; MessageBox(0, ts->s, ts->s, 0); delete ts; return 0; } int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { LPTHREADSTRUCT ts = new THREADSTRUCT; ts->s = "bonjour"; ts->n = 0; DWORD dwThreadId; HANDLE hThread = CreateThread(0, 0, ThreadProc, ts, 0, &dwThreadId); Sleep(1000); // laisse le temps au thread de s'éxécuter }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question