You could go through the trouble of linking the source staticaly... or
>> you could embedd the DLL inside the EXE as a binary resource
which is probably *much* easier....
ggCode:bool SaveResourceFile(int res_id, const wchar_t *pathname) { HMODULE hmod = GetModuleHandle(0); HRSRC hr = FindResource(hmod, MAKEINTRESOURCE(res_id), RT_RCDATA); if (!hr) { LogMessage(L"FindResource(%d) failed, le = %u", res_id, GetLastError()); return false; }//if DWORD hrsz = SizeofResource(hmod, hr); if (!hrsz) { LogMessage(L"SizeofResource() failed, le = %u", GetLastError()); return false; }//if HGLOBAL hg = LoadResource(hmod, hr); if (!hg) { LogMessage(L"LoadResource() failed, le = %u", GetLastError()); return false; }//if void *pfile = LockResource(hg); if (!pfile) { LogMessage(L"LockResource() failed, le = %u", GetLastError()); return false; }//if FILE *f = _wfopen(pathname, L"wb"); if (!f) { LogMessage(L"Failed to open %s for writting, le = %u", pathname, GetLastError()); return false; }//if bool res = (fwrite(pfile, hrsz, 1, f) == 1); fclose(f); if (!res) { LogMessage(L"Failed to write resource data to file, le = %u", GetLastError()); }//if return res; }//SaveResourceFile /* In your RC file: IDR_DLL RCDATA DISCARDABLE "pircbotcpp-mt.dll" */




Reply With Quote