/**
 * \brief Thread that create window and that monitor event related to it.
 * \param pThreadParam thread parameter
 * \return 0
 */
static unsigned WINAPI CreateWndThreadW(LPVOID pThreadParam)
{
  HINSTANCE hInstance = GetModuleHandle(NULL);
  keyboard_hook* keyboard = (keyboard_hook*)pThreadParam;

  RegisterWindowClassW(hInstance);

  HWND hWnd = CreateWindowW(WINDOW_SHORTCUT_NAME, NULL, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
      NULL, NULL, hInstance, NULL);
  keyboard->hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyHandler, NULL, 0);

  if(hWnd == NULL)
  {
    fprintf(stderr, "Failed to create window: %d\n", GetLastError());
    fflush(stderr);
    return 0;
  }
  else
  {
    MSG msg;

    keyboard->hwnd = hWnd;
    PostMessage(keyboard->hwnd, WM_HOTKEY, 0, 0);

    while(GetMessageW(&msg, hWnd, 0, 0))
    {
      TranslateMessage(&msg);
      DispatchMessageW(&msg);
    }
    return msg.wParam;
  }
}
unsigned WINAPI CreateWndThreadW(LPVOID pThreadParam)
{
    hInstance = GetModuleHandle (NULL);
    RegisterWindowClassW();

    /*
    hhookSysMsg = SetWindowsHookEx(
                    WH_MSGFILTER,
                    (HOOKPROC)msghook,
                    hInstance,
                    GetCurrentThreadId());
    if(hhookSysMsg == NULL)
    {
        fprintf(stderr, "Failed to create hoook %i\n", GetLastError() );
        fflush(stderr);
    }
    */

    HWND hWnd = CreateWindowW( L"Jitsi Window Hook", NULL, WS_OVERLAPPEDWINDOW,
                               CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                               NULL, NULL, hInstance, NULL);
    if( hWnd == NULL)
    {
        fprintf(stderr, "Failed to create window\n" );
        fflush(stderr);

        return( 0 );

    } else
    {
        MSG Msg;

        while(GetMessageW(&Msg, hWnd, 0, 0)) {

            TranslateMessage(&Msg);

            DispatchMessageW(&Msg);
        }

        return Msg.wParam;
    }
}
Пример #3
0
BOOL APIENTRY 
DllMain( 
	HINSTANCE	hModule, 
    DWORD		ul_reason_for_call, 
    LPVOID		lpReserved )
{
    switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
		{
			hInstance	= hModule;

			OSVERSIONINFOA	osvi;

			application_module = (HMODULE)hModule;

			osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);

			GetVersionExA(&osvi);

			non_unicode = ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS );

			if ( non_unicode ){
				RegisterWindowClassA();
			}else{
				RegisterWindowClassW();
			}

			break;
		}
		case DLL_THREAD_ATTACH:
		case DLL_THREAD_DETACH:
		case DLL_PROCESS_DETACH:
			break;
    }
    return TRUE;
}