Проверка принадлежности потока BOOL CheckCurrentProcess(DWORD dwThreadID )
{
	HANDLE				hSnapshot;
	BOOL				bRet = TRUE;
	BOOL				bCont;
	THREADENTRY32		meThreadEntry;
	DWORD dwProceessID = GetCurrentProcessId();
	hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD,0 );
	if( hSnapshot != NULL )
	{
		meThreadEntry.dwSize = sizeof( THREADENTRY32 );
		bCont = Thread32First( hSnapshot,&meThreadEntry );
		while( bCont && bRet )
		{
			if( ( meThreadEntry.th32ThreadID == dwThreadID ) && ( meThreadEntry.th32OwnerProcessID == dwProceessID ) )
				bRet = FALSE;
			else
				bCont = Thread32Next( hSnapshot,&meThreadEntry );
		}
		CloseHandle( hSnapshot );
	}
	return bRet;
}