The easiest, least sloppy way is to use the lpParameter on CreateThread()...
Cast the data you want to send to LVOID (you can send a pointer to whatever), and recast it to what you want in the tread proc
Code:
#include <windows.h>
DWORD WINAPI ThreadFunc(LPVOID lParam){
MessageBox(HWND_DESKTOP,(LPSTR)lParam,NULL,MB_OK);
return 0;
}
int main(void){
DWORD dwTID;
HANDLE hThread;
char buff[] = "Hello from thread!!!!";
hThread = CreateThread(NULL,NULL,ThreadFunc,(LPVOID)buff,NULL,&dwTID);
WaitForSingleObject(hThread,INFINITE);//let thread end
return 0;
}
As a word of caution, beware CreateThread when using std functions.......Your compiler will most likely have a better safer version of the func (__beginthreadex() in VC++)