I am using this code to load a DLL and call its functions
The problem is hmod is returning false. I traced it by putting a messagebox in this code segmentCode:HRESULT InitMCBandFunction() { HRESULT hr; HMODULE hmod = GetModuleHandle(L"MCBand.dll"); if (hmod) { g_fctShowMCPaneBrowserBar = (FCTSHOWMCPANEBROWSERBAR)GetProcAddress( hmod, "ShowMCPaneBrowserBar"); if (g_fctShowMCPaneBrowserBar) { hr = S_OK; } else { hr = HRESULTFromGetLastError(); } // Don't call FreeLibrary! } else { hr = HRESULTFromGetLastError(); } return hr; }
Can anyone tell me what is the problem with this code segment? why is it returning false??Code:if (hmod) { g_fctShowMCPaneBrowserBar = (FCTSHOWMCPANEBROWSERBAR)GetProcAddress( hmod, "ShowMCPaneBrowserBar"); MessageBoxA (NULL, "This is a Test Message", "", MB_HELP); ----------------------------------------------- ----------------------------------------------- }
since I am using this entire code in a DLL not an MFC application therefore i am unable to see the status of get last error, cuz i can't debug it. Can anyone tell me the solution of this??
in this sectionif I specify the complete path of the DLL will it work??Code:HMODULE hmod = GetModuleHandle(L"MCBand.dll");




Reply With Quote