loadlibrary

LoadLibrary failed with error code 126 if app started from installation option

可紊 提交于 2019-11-28 11:05:03
问题 I have two application and install in different folders, let call it app A and B, A is main application and B is an COM module, A will start B through COM API after A started, there are some DLLs need to be loaded by B while B started, if I start A by double click the shortcut of A, every thing is ok, but if I install A, and start A by check the start A option in the last dialog of the installation, then B is started, but one of the DLLs load failed with error code 126 (ERROR_MOD_NOT_FOUND),

How to check a DLL if a function exists?

被刻印的时光 ゝ 提交于 2019-11-28 10:23:47
I'm working on something which dynamically loads specially formulated DLL's. I need to be able to check the DLL and make sure all the expected functions exist before I consider using this DLL. If it's missing some certain functions, I should not try to load it. I know I could attempt to call one of the functions and see if there's an exception, but I would see errors in debug mode. How should I go about checking a DLL if a function exists? I'd like to check it before I load it (using LoadLibrary ) but I guess it's OK if I have to load it to perform this check too. UPDATE I've accepted David's

embed DLL in MFC C++ EXE?

纵然是瞬间 提交于 2019-11-28 05:16:50
问题 Is it possible to embed an external CLI/C++ DLL into a MFC EXE as a embedded resource or something like that? My application currently connects to DLL sitting right beside it that has some basic functions like connect to database, pull information from DB, etc.. I use LoadLibrary to use the DLL functions. Then I secure my EXE with themida and pack the EXE and DLL together. The problem is though to pack the DLL and EXE I have to disable file patching in themida which is a very strong feature.

How do I use a COM DLL with LoadLibrary in C++

旧时模样 提交于 2019-11-27 21:56:12
问题 First, COM is like black magic for me. But I need to use COM dll in one project I'm working on. So, I have a DLL I am developing and I need some functionalities that are available in a separate COM DLL. When I look to the COM DLL with Depends.exe I see methods like DllGetClassObject() and other functions but none of the functions I'm interested in. I have access to the COM DLL (legacy) source code but it's a mess and I'd rather like to use the COM DLL in binary like a big black box not

GetProcAddress function in C++

痴心易碎 提交于 2019-11-27 19:51:15
Hello guys: I've loaded my DLL in my project but whenever I use the GetProcAddress function. it returns NULL! what should I do? I use this function ( double GetNumber(double x) ) in "MYDLL.dll" Here is a code which I used: typedef double (*LPGETNUMBER)(double Nbr); HINSTANCE hDLL = NULL; LPGETNUMBER lpGetNumber; hDLL = LoadLibrary(L"MYDLL.DLL"); lpGetNumber = (LPGETNUMBER)GetProcAddress((HMODULE)hDLL, "GetNumber"); Checking return codes and calling GetLastError() will set you free. You should be checking return codes twice here. You are actually checking return codes zero times. hDLL =

LoadLibrary加载动态库失败

孤者浪人 提交于 2019-11-27 18:10:50
LoadLibrary加载动态库失败的可能原因以及解决方案: (1)dll动态库文件路径不对。此场景细分为以下几种情况: 1.1 文件路径的确错误 。比如:本来欲加载的是A文件夹下的动态库a.dll,但是经过仔细排查原因,发现a.dll动态库竟然被拷贝到B文件夹下去了。 若真遇到这种低级错误,建议你找个没人的墙角蹲下用小拇指逆时针划圈圈去吧。。。 1.2 实参传值错误。比如:实参类型为LPCWTR,经常都会因为字符串转换导致实参事与愿违。 网上的经验总结实例。某程序员经过一番周折后通过以下语句调用成功 hDll = LoadLibrary(TEXT("user32.dll")); 再经过一番百度google后发现,原来是字符格式惹的祸。 这里的LoadLibrary实际使用了LoadLibraryW而非LoadLibraryA,因此需要UNICODE字符串(宽字符串),而非窄字符串。 如下: #ifdef UNICODE #define LoadLibrary LoadLibraryW #else #define LoadLibrary LoadLibraryA #endif // !UNICODE 在C/C++代码中,直接使用""定义的字符串为窄字节串,而windows头文件中提供的TEXT宏可以根据是否定义了UNICODE宏来自动选择字符串类型。 因此,利用

Is there a better way to load a dll in C++?

久未见 提交于 2019-11-27 11:22:39
问题 Right now I do something like this and it seems messy if I end having a lot of functions I want to reference in my DLL. Is there a better and cleaner way of accessing the functions without having to create a typedef for each function definition so that it will compile and load the function properly. I mean the function definitions are already in the .h file and I shouldn't have to redeclare them after I load the function (or do I?) Is there a better solution than using LoadLibary? I don't

Load the same dll multiple times [closed]

怎甘沉沦 提交于 2019-11-27 09:42:21
I want to load the same dll e.g. Lib.dll multiple times! -> need creating a new process (CreateProcess function) for every LoadLibrary! Anyone have an example or some hints?! Thx and greets It sounds like you want each instance of the DLL to have separate data segments. That's the only reason I can think of for the question. The only way to achieve this is to make sure that each time you call LoadLibrary , the DLL has a different filename. Copy the DLL to a temporary file each time you need to load it, making sure that the name you use is different from any loaded instance of the DLL. I echo

Loading a dll from a dll?

徘徊边缘 提交于 2019-11-27 06:56:16
What's the best way for loading a dll from a dll ? My problem is I can't load a dll on process_attach, and I cannot load the dll from the main program, because I don't control the main program source. And therefore I cannot call a non-dllmain function, too. After all the debate that went on in the comments, I think that it's better to summarize my positions in a "real" answer. First of all, it's still not clear why you need to load a dll in DllMain with LoadLibrary. This is definitely a bad idea, since your DllMain is running inside another call to LoadLibrary, which holds the loader lock, as

Passing pointer argument in MATLAB to a C-DLL function foo(char**)

孤人 提交于 2019-11-27 06:22:13
问题 I am writing a C-DLL to be called from MATLAB. Is it possible to call a function with const char ** parameter? e.g. void myGetVersion( const char ** ); The C code would be: const char *version=0; myGetVersion( &version ); What would be corresponding MATLAB-Code (if it is possible at all)? Thank you very much! P.S.: I think this is the help page, but I couldn't find my case :-( 回答1: The answer is to build a pointer to a c-string using the LIBPOINTER function as @JonasHeidelberg suggested. Let