/** * Create the dll objects. This functions loads the appropriate dll. */ HRESULT ZFXInput::CreateDevice() { // load the DLL containing interface implementation m_hDLL = LoadLibraryEx(L"ZFXDI.dll", NULL, 0); if (!m_hDLL) { MessageBox(NULL, L"Loading ZFXDI.dll from lib failed.", L"ZFXEngine - error", MB_OK | MB_ICONERROR); return E_FAIL; } CREATEINPUTDEVICE _CreateInputDevice = 0; HRESULT hr; // function pointer to dll's 'CreateInputDevice' function _CreateInputDevice = (CREATEINPUTDEVICE) GetProcAddress(m_hDLL, "CreateInputDevice"); // call dll's create function hr = _CreateInputDevice(m_hDLL, &m_pDevice); if (FAILED(hr)) { MessageBox(NULL, L"CreateInputDevice() from lib failed.", L"ZFXEngine - error", MB_OK | MB_ICONERROR); m_pDevice = NULL; return E_FAIL; } return S_OK; } // CreateDevice
//Carrega a dll requerida HRESULT ACInput::CreateDevice(const std::string& inputLibraryName) { // carrega a dll com a implementacao da interface mhDLL = LoadLibraryExA(inputLibraryName.c_str(),nullptr,0); if(!mhDLL) return E_FAIL; CREATEINPUTDEVICE _CreateInputDevice = 0; HRESULT hr; // ponteiro para a funciona da dll 'CreateInputDevice' function _CreateInputDevice = (CREATEINPUTDEVICE) GetProcAddress(mhDLL, "CreateInputDevice"); // call dll create function hr = _CreateInputDevice(mhDLL, &mpDevice); if(FAILED(hr)) { mpDevice = nullptr; return E_FAIL; } return S_OK; };