// JP opened flex table

Click to See Complete Forum and Search --> : Creating Thread for a window in DLL


Atomsk47
July 1st, 2008, 04:34 PM
ok I am working on creating a plugin for iTunes and this is what I have so far. Right now it is just creating a thread for the window creation and gets the handle from iTunes. Only problem is as soon as I click ok on the debug messagebox inside the thread the application AND iTunes close. No error message or anything just closes and I am at a loss. I am very new Windows DLL programing and any help would be greatly appreciated.

unsigned __stdcall ThreadFunc( void* pArguments )
{

MessageBox(NULL, _T("Inside Thread"), _T("iTunes Debug"), MB_OK);
hWnd = FindWindow(_T("iTunes"),NULL);
if(hWnd==NULL)
MessageBox(NULL, _T("Grabbing handle from iTunes failed..."), _T("iTunes Lyrics DLL"), MB_OK);
else
MessageBox(NULL, _T("Successfully grabbed handle from iTunes..."), _T("iTunes Lyrics DLL"), MB_OK);
_endthreadex( 0 );
return 0;
}

BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
hInstance = (HINSTANCE)GetModuleHandle(_T("iTunesLyrics"));
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
_beginthreadex(NULL, 0, &ThreadFunc, NULL, 0, 0);break;
case DLL_THREAD_ATTACH:
case DLL_PROCESS_DETACH:
case DLL_THREAD_DETACH:
break;
}
return true;

}

//JP added flex table