本文整理汇总了C++中LoadLibraryEx函数的典型用法代码示例。如果您正苦于以下问题:C++ LoadLibraryEx函数的具体用法?C++ LoadLibraryEx怎么用?C++ LoadLibraryEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoadLibraryEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetModuleFileName
HRESULT CLAVAudio::InitDTSDecoder()
{
if (!m_hDllExtraDecoder) {
// Add path of LAVAudio.ax into the Dll search path
WCHAR wModuleFile[1024];
GetModuleFileName(g_hInst, wModuleFile, 1024);
PathRemoveFileSpecW(wModuleFile);
wcscat_s(wModuleFile, TEXT("\\dtsdecoderdll.dll"));
// Try loading from the filters directory
HMODULE hDll = LoadLibraryEx(wModuleFile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
// And try from any global directories if this failed
if (hDll == NULL) {
hDll = LoadLibrary(TEXT("dtsdecoderdll.dll"));
}
CheckPointer(hDll, E_FAIL);
m_hDllExtraDecoder = hDll;
}
DTSDecoder *context = new DTSDecoder();
context->pDtsOpen = (DtsOpen)GetProcAddress(m_hDllExtraDecoder, "DtsApiDecOpen");
if(!context->pDtsOpen) goto fail;
context->pDtsClose = (DtsClose)GetProcAddress(m_hDllExtraDecoder, "DtsApiDecClose");
if(!context->pDtsClose) goto fail;
context->pDtsReset = (DtsReset)GetProcAddress(m_hDllExtraDecoder, "DtsApiDecReset");
if(!context->pDtsReset) goto fail;
context->pDtsSetParam = (DtsSetParam)GetProcAddress(m_hDllExtraDecoder, "DtsApiDecSetParam");
if(!context->pDtsSetParam) goto fail;
context->pDtsDecode = (DtsDecode)GetProcAddress(m_hDllExtraDecoder, "DtsApiDecodeData");
if(!context->pDtsDecode) goto fail;
context->dtsContext = context->pDtsOpen();
if(!context->dtsContext) goto fail;
context->dtsPCMBuffer = (BYTE *)av_mallocz(LAV_AUDIO_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
m_DTSBitDepth = 24;
m_DTSDecodeChannels = 8;
m_pDTSDecoderContext = context;
FlushDTSDecoder();
return S_OK;
fail:
SAFE_DELETE(context);
FreeLibrary(m_hDllExtraDecoder);
m_hDllExtraDecoder = NULL;
return E_FAIL;
}
示例2: ReadMPQFiles
bool ReadMPQFiles() {
FILE *phil;
phil = fopen("C:\\philtest.txt", "a+"); fprintf(phil, "phil reading files\n"); fclose(phil);
int fileCount = 0;
HMODULE hModule = GetModuleHandle("StormLib.dll");
if (hModule) {
phil = fopen("C:\\philtest.txt", "a+"); fprintf(phil, "phil dll already loaded\n"); fclose(phil);
}
//HMODULE dllHandle = LoadLibrary("StormLib.dll");
HMODULE dllHandle = LoadLibraryEx("StormLib.dll", NULL, LOAD_IGNORE_CODE_AUTHZ_LEVEL);
phil = fopen("C:\\philtest.txt", "a+"); fprintf(phil, "here with xhandle %d\n", (int)dllHandle); fclose(phil);
if (dllHandle) {
phil = fopen("C:\\philtest.txt", "a+"); fprintf(phil, "opened dll!\n"); fclose(phil);
SFileOpenArchive = (MPQOpenArchive)GetProcAddress(dllHandle, "SFileOpenArchive");
SFileCloseArchive = (MPQCloseArchive)GetProcAddress(dllHandle, "SFileCloseArchive");
SFileOpenFileEx = (MPQOpenFile)GetProcAddress(dllHandle, "SFileOpenFileEx");
SFileGetFileSize = (MPQGetSize)GetProcAddress(dllHandle, "SFileGetFileSize");
SFileReadFile = (MPQReadFile)GetProcAddress(dllHandle, "SFileReadFile");
SFileCloseFile = (MPQCloseFile)GetProcAddress(dllHandle, "SFileCloseFile");
if (SFileOpenArchive && SFileCloseArchive && SFileOpenFileEx && SFileCloseFile && SFileGetFileSize && SFileReadFile) {
HANDLE hMpq = NULL;
MPQArchive archive("phil.mpq"); // phil fixme phil
if (archive.error == ERROR_SUCCESS) {
phil = fopen("C:\\philtest.txt", "a+"); fprintf(phil, "opened the archive\n"); fclose(phil);
MPQFile armorFile(&archive, "Armor.txt");
if (armorFile.error == ERROR_SUCCESS) {
fileCount++;
MpqDataMap["armor"] = new MPQData(&armorFile);
}
MPQFile weaponsFile(&archive, "Weapons.txt");
if (weaponsFile.error == ERROR_SUCCESS) {
fileCount++;
MpqDataMap["weapons"] = new MPQData(&weaponsFile);
}
MPQFile miscFile(&archive, "Misc.txt");
if (miscFile.error == ERROR_SUCCESS) {
fileCount++;
MpqDataMap["misc"] = new MPQData(&miscFile);
}
MPQFile itemTypesFile(&archive, "ItemTypes.txt");
if (itemTypesFile.error == ERROR_SUCCESS) {
fileCount++;
MpqDataMap["itemtypes"] = new MPQData(&itemTypesFile);
}
phil = fopen("C:\\philtest.txt", "a+"); fprintf(phil, "file errors %d, %d, %d, %d\n", armorFile.error, weaponsFile.error, miscFile.error, itemTypesFile.error); fclose(phil);
}
phil = fopen("C:\\philtest.txt", "a+"); fprintf(phil, "archive error %d\n", archive.error); fclose(phil);
}
FreeLibrary(dllHandle);
} else {
phil = fopen("C:\\philtest.txt", "a+"); fprintf(phil, "couldn't open dll: %d\n", GetLastError()); fclose(phil);
}
phil = fopen("C:\\philtest.txt", "a+"); fprintf(phil, "file count is %d\n", fileCount); fclose(phil);
return fileCount == 4;
}
示例3: LoadLibraryEx
bool PluginLoader::getScyllaPluginName(Plugin * pluginData)
{
bool retValue = false;
char * pluginName = 0;
def_ScyllaPluginNameW ScyllaPluginNameW = 0;
def_ScyllaPluginNameA ScyllaPluginNameA = 0;
HMODULE hModule = LoadLibraryEx(pluginData->fullpath, 0, DONT_RESOLVE_DLL_REFERENCES); //do not call DllMain
if (hModule)
{
ScyllaPluginNameW = (def_ScyllaPluginNameW)GetProcAddress(hModule, "ScyllaPluginNameW");
if (ScyllaPluginNameW)
{
wcscpy_s(pluginData->pluginName, ScyllaPluginNameW());
#ifdef DEBUG_COMMENTS
Scylla::debugLog.log(L"getPluginName :: Plugin name %s", pluginData->pluginName);
#endif
retValue = true;
}
else
{
ScyllaPluginNameA = (def_ScyllaPluginNameA)GetProcAddress(hModule, "ScyllaPluginNameA");
if (ScyllaPluginNameA)
{
pluginName = ScyllaPluginNameA();
StringConversion::ToUTF16(pluginName, pluginData->pluginName, _countof(pluginData->pluginName));
#ifdef DEBUG_COMMENTS
Scylla::debugLog.log(L"getPluginName :: Plugin name mbstowcs_s %s", pluginData->pluginName);
#endif
if (wcslen(pluginData->pluginName) > 1)
{
retValue = true;
}
}
}
FreeLibrary(hModule);
return retValue;
}
else
{
#ifdef DEBUG_COMMENTS
Scylla::debugLog.log(L"getPluginName :: LoadLibraryEx failed %s", pluginData->fullpath);
#endif
return false;
}
}
示例4: ShellExecute
bool CUpdateUtil::RegisterOLE(CString pszDllName, CString pszDllEntryPoint)
{
::CoInitialize(NULL);
bool bReturn = false;
CString strTempFileName = pszDllName;
strTempFileName.MakeLower();
if(strTempFileName.Find(".exe") > 0)
{
strTempFileName += " /RegServer";
ShellExecute(NULL, NULL, strTempFileName, NULL, NULL, SW_HIDE);
bReturn = true;
}
else
{
// Load the library.
HINSTANCE hLib = LoadLibraryEx(pszDllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (hLib < (HINSTANCE)HINSTANCE_ERROR) {
SetLastError(UPDATE_ERROR_DLL_LOAD_LIBRARY);
TRACE("UPDATE_ERROR_DLL_LOAD_LIBRARY : %s\n", pszDllName);
goto CleanupOle;
}
// Find the entry point.
FARPROC lpDllEntryPoint;
(FARPROC&)lpDllEntryPoint = GetProcAddress(hLib, pszDllEntryPoint);
if (lpDllEntryPoint == NULL) {
SetLastError(UPDATE_ERROR_DLL_GET_PROC_ADDRESS);
TRACE("UPDATE_ERROR_DLL_GET_PROC_ADDRESS : %s\n", pszDllName);
goto CleanupLibrary;
}
// Call the entry point.
if (lpDllEntryPoint)
{
if(Error((*lpDllEntryPoint)()) )
goto CleanupLibrary;
}
SetLastError(UPDATE_SUCCESS_REGSVR_DLL);
TRACE("UPDATE_SUCCESS_REGSVR_DLL : %s\n", pszDllName);
//Horray
bReturn = true;
CleanupLibrary:
FreeLibrary(hLib);
CleanupOle:
OleUninitialize();
}
::CoUninitialize();
return bReturn;
}
示例5: render_message
std::wstring render_message(const int truncate_message, DWORD dwLang = 0) const {
std::vector<std::wstring> args;
std::wstring ret;
std::wstring file;
if (!get_dll(file)) {
return file;
}
strEx::splitList dlls = strEx::splitEx(file, _T(";"));
for (strEx::splitList::const_iterator cit = dlls.begin(); cit != dlls.end(); ++cit) {
//std::wstring msg = error::format::message::from_module((*cit), eventID(), _sz);
std::wstring msg;
try {
HMODULE hDLL = LoadLibraryEx((*cit).c_str(), NULL, DONT_RESOLVE_DLL_REFERENCES);
if (hDLL == NULL) {
msg = _T("failed to load: ") + (*cit) + _T(", reason: ") + strEx::itos(GetLastError());
continue;
}
if (dwLang == 0)
dwLang = MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT);
boost::tuple<DWORD,std::wstring> formated_data = safe_format(hDLL, dwLang);
if (formated_data.get<0>() != 0) {
FreeLibrary(hDLL);
if (formated_data.get<0>() == 15100) {
// Invalid MUI file (wrong language)
msg = _T("");
continue;
}
if (formated_data.get<0>() == 317) {
// Missing message
msg = _T("");
continue;
}
msg = _T("failed to lookup error code: ") + strEx::itos(eventID()) + _T(" from DLL: ") + (*cit) + _T("( reason: ") + strEx::itos(formated_data.get<0>()) + _T(")");
continue;
}
FreeLibrary(hDLL);
msg = formated_data.get<1>();
} catch (...) {
msg = _T("Unknown exception getting message");
}
strEx::replace(msg, _T("\n"), _T(" "));
strEx::replace(msg, _T("\t"), _T(" "));
std::string::size_type pos = msg.find_last_not_of(_T("\n\t "));
if (pos != std::string::npos) {
msg = msg.substr(0,pos);
}
if (!msg.empty()) {
if (!ret.empty())
ret += _T(", ");
ret += msg;
}
}
if (truncate_message > 0 && ret.length() > truncate_message)
ret = ret.substr(0, truncate_message);
return ret;
}
示例6: LoadLibraryEx
BOOL CVersionInfo::LoadVersionInfoResource(const CString& strModulePath, CVersionInfoBuffer &viBuf, LPCTSTR lpszResourceId, WORD wLangId)
{
HRSRC hResInfo;
HMODULE hModule = LoadLibraryEx(strModulePath, NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
if (NULL == hModule)
return FALSE;
if ((NULL == lpszResourceId) && (wLangId == 0xFFFF))
{
//Load first RT_VERSION resource that will be found
m_lpszResourceId = NULL;
EnumResourceNames(hModule, RT_VERSION, (ENUMRESNAMEPROC)EnumResourceNamesFuncFindFirst, (LONG_PTR)this);
if (NULL == m_lpszResourceId)
{
FreeLibrary(hModule);
return FALSE;
}
// Now the m_lpszResourceId must be the name of the resource
m_wLangId = 0xFFFF;
EnumResourceLanguages(hModule, RT_VERSION, m_lpszResourceId, (ENUMRESLANGPROC)EnumResourceLangFuncFindFirst, (LONG_PTR)this);
// Found resource, copy the ID's to local vars
lpszResourceId = m_lpszResourceId;
wLangId = m_wLangId;
}
hResInfo = FindResourceEx(hModule, RT_VERSION, lpszResourceId, wLangId);
// Write the resource language to the resource information file.
DWORD dwSize = SizeofResource(hModule, hResInfo);
if (dwSize)
{
HGLOBAL hgRes = LoadResource(hModule, hResInfo);
if (hgRes)
{
LPVOID lpMemory = LockResource(hgRes);
if (lpMemory)
{
viBuf.Write(lpMemory,dwSize);
UnlockResource(hgRes);
FreeLibrary(hModule);
return TRUE;
}
}
}
FreeLibrary(hModule);
return FALSE;
}
示例7: dl_open
static void*
dl_open(const char* name, int flags)
{
if (name == NULL) {
return GetModuleHandle(NULL);
} else {
DWORD dwFlags = PathIsRelative(name) ? 0 : LOAD_WITH_ALTERED_SEARCH_PATH;
return LoadLibraryEx(name, NULL, dwFlags);
}
}
示例8: caml_dlopen
void * caml_dlopen(char * libname, int for_execution)
{
HMODULE m;
m = LoadLibraryEx(libname, NULL,
for_execution ? 0 : DONT_RESOLVE_DLL_REFERENCES);
/* Under Win 95/98/ME, LoadLibraryEx can fail in cases where LoadLibrary
would succeed. Just try again with LoadLibrary for good measure. */
if (m == NULL) m = LoadLibrary(libname);
return (void *) m;
}
示例9: getMaxIconId
WORD getMaxIconId(TCHAR* lpFileName)
{
WORD nMaxID = 0;
HINSTANCE hLib = LoadLibraryEx(lpFileName,NULL,DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
if(hLib == NULL) { _tprintf(_T("Unable to load library '%s'\n"), lpFileName); return 0xFFFF; }
// Enumerate icon "names" (IDs) to get next available ID
if(!EnumResourceNames(hLib, RT_ICON, (ENUMRESNAMEPROC)getMaxIconId_EnumNamesFunc,(LONG_PTR)&nMaxID)) { _tprintf(_T("Unable to enum icons\n")); return 0xFFFF; }
FreeLibrary(hLib);
IFDEBUG( _tprintf(_T("MaxIcon=%d\n"), nMaxID); )
return nMaxID;
示例10: Win32SecureLoadLibraryEx
// DLL reading for Win32
HINSTANCE Win32SecureLoadLibraryEx(char *dllname, DWORD flags)
{
char tmp1[MAX_PATH];
char tmp2[MAX_PATH];
char tmp3[MAX_PATH];
HINSTANCE h;
// Validate arguments
if (dllname == NULL)
{
return NULL;
}
Format(tmp1, sizeof(tmp1), "%s\\%s", MsGetSystem32Dir(), dllname);
Format(tmp2, sizeof(tmp2), "%s\\JPKI\\%s", MsGetProgramFilesDir(), dllname);
Format(tmp3, sizeof(tmp3), "%s\\LGWAN\\%s", MsGetProgramFilesDir(), dllname);
h = LoadLibraryEx(dllname, NULL, flags);
if (h != NULL)
{
return h;
}
h = LoadLibraryEx(tmp1, NULL, flags);
if (h != NULL)
{
return h;
}
h = LoadLibraryEx(tmp2, NULL, flags);
if (h != NULL)
{
return h;
}
h = LoadLibraryEx(tmp3, NULL, flags);
if (h != NULL)
{
return h;
}
return NULL;
}
示例11: RegDll
void RegDll(char *file)
{
HMODULE mod = LoadLibraryEx(file, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (mod)
{
FARPROC regfunc = GetProcAddress(mod, "DllRegisterServer");
if (regfunc)
regfunc();
FreeLibrary(mod);
}
}
示例12: InternalLoadLibrary
// wraps LoadLibraryEx() since 360 doesn't support that
static HMODULE InternalLoadLibrary( const char *pName, Sys_Flags flags )
{
#if defined(_X360)
return LoadLibrary( pName );
#else
if ( flags & SYS_NOLOAD )
return GetModuleHandle( pName );
else
return LoadLibraryEx( pName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
#endif
}
示例13: loadLibraryEx
// ----------------------------------------------------------------------------------
HMODULE loadLibraryEx(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFlags)
{
HMODULE hExe;
hExe = LoadLibraryEx(TEXT(lpFileName), hFile, dwFlags);
if (hExe == NULL)
{
QTextStream(stdout, QIODevice::WriteOnly) << "Could not load .exe " << lpFileName << "\n";
return 0;
}
return hExe;
}
示例14: hbwapi_LoadLibrarySystem
HMODULE hbwapi_LoadLibrarySystem( LPCTSTR pFileName )
{
TCHAR * pLibPath = hbwapi_FileNameAtSystemDir( pFileName );
/* TODO: Replace flag with LOAD_LIBRARY_SEARCH_SYSTEM32 in the future [vszakats] */
HMODULE h = LoadLibraryEx( pLibPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
hb_xfree( pLibPath );
return h;
}
示例15: LoadLibraryEx
Trans2QuikApi::Trans2QuikApi(const std::string& dll)
{
m_handle = LoadLibraryEx(dll.c_str(), NULL, 0);
if(!m_handle)
throw std::runtime_error("Unable to load dll");
LOAD_SYMBOL_2(TRANS2QUIK_CONNECT, 16);
LOAD_SYMBOL_2(TRANS2QUIK_DISCONNECT, 12);
LOAD_SYMBOL_2(TRANS2QUIK_IS_QUIK_CONNECTED, 12);
LOAD_SYMBOL_2(TRANS2QUIK_IS_DLL_CONNECTED, 12);
LOAD_SYMBOL_2(TRANS2QUIK_SEND_SYNC_TRANSACTION, 36);
LOAD_SYMBOL_2(TRANS2QUIK_SEND_ASYNC_TRANSACTION, 16);
LOAD_SYMBOL_2(TRANS2QUIK_SET_CONNECTION_STATUS_CALLBACK, 16);
LOAD_SYMBOL_2(TRANS2QUIK_SET_TRANSACTIONS_REPLY_CALLBACK, 16);
LOAD_SYMBOL_2(TRANS2QUIK_SUBSCRIBE_ORDERS, 8);
LOAD_SYMBOL_2(TRANS2QUIK_SUBSCRIBE_TRADES, 8);
LOAD_SYMBOL_2(TRANS2QUIK_START_ORDERS, 4);
LOAD_SYMBOL_2(TRANS2QUIK_START_TRADES, 4);
LOAD_SYMBOL_2(TRANS2QUIK_UNSUBSCRIBE_ORDERS, 0);
LOAD_SYMBOL_2(TRANS2QUIK_UNSUBSCRIBE_TRADES, 0);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_DATE, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_SETTLE_DATE, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_TIME, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_IS_MARGINAL, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_ACCRUED_INT, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_YIELD, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_TS_COMMISSION, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_CLEARING_CENTER_COMMISSION, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_EXCHANGE_COMMISSION, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_TRADING_SYSTEM_COMMISSION, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_PRICE2, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_REPO_RATE, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_REPO_VALUE, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_REPO2_VALUE, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_ACCRUED_INT2, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_REPO_TERM, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_START_DISCOUNT, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_LOWER_DISCOUNT, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_UPPER_DISCOUNT, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_BLOCK_SECURITIES, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_DATE_TIME, 8);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_CURRENCY, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_SETTLE_CURRENCY, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_SETTLE_CODE, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_ACCOUNT, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_BROKERREF, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_CLIENT_CODE, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_USERID, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_FIRMID, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_PARTNER_FIRMID, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_EXCHANGE_CODE, 4);
LOAD_SYMBOL_2(TRANS2QUIK_TRADE_STATION_ID, 4);
}