|
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 |
1. Load DLL Failed? #2707 |
Hi, i try this method, but prompt me error message.. :(
#include "wx/dynlib.h" ...
wxDllLoader *mydll = LoadLibrary("mylib.dll");
163 C:main.cpp cannot convert `HINSTANCE__*' to `wxDllLoader*' in initialization
163 C:main.cpp [Warning] unused variable `wxDllLoader*mydll'
what is the different between wxDllLoader and wxDynamicLibrary?
Thank you.Meow~ |
2. Re: Load DLL Failed? #2708 Posted by: 2003-10-07 20:54:43 |
I think you're asking a win32 function to return a wxWindows type, try
wxDllType *mydll = wxDllLoader::LoadLibrary("mylib"); wxDllLoader is provided for using static methods, whereas wxDynamicLibrary is a wrapper around it so you may derive your own classes. |
3. Re: Load DLL Failed? #2711 |
Hi Adam, still prompt me error message.. :(
cannot convert `HINSTANCE__*' to `HINSTANCE__**' in
[Warning] unused variable `HINSTANCE__**mydll'
Thank youMeow~ |
4. Re: Load DLL Failed? #2712 Posted by: 2003-10-08 08:11:07 |
Sorry I left an * in there when I copied your code, it should have been:
wxDllType mydll = wxDllLoader::LoadLibrary("mylib"); |
5. Re: Load DLL Failed? #2715 |
Hi Adam,
still prompt me error message.. :(
[Warning] unused variable `HINSTANCE__*mydll'Meow~ |
6. Re: Load DLL Failed? #2717 Posted by: 2003-10-08 21:35:05 |
It's moaning becase you havn't used the handle you created, you have to do something with it, e.g. Get a system beep on Win32:
wxDllType mydll = wxDllLoader::LoadLibrary("user32");
typedef bool (*winbeeptype)(unsigned int);
winbeeptype win32_beep = (winbeeptype) wxDllLoader::GetSymbol(mydll, "MessageBeep");
win32_beep(0xFFFFFFFF); |
7. Re: Load DLL Failed? #2718 |
Hi Adam,
why we need to do like this? Would you mind explain/describe for me about these following codes?
typedef bool (*winbeeptype)(unsigned int);
winbeeptype win32_beep = (winbeeptype) wxDllLoader::GetSymbol(mydll, "MessageBeep");
Thank you.Meow~ |
8. Re: Load DLL Failed? #2720 Posted by: 2003-10-09 17:20:51 |
Sure, I can try, although all this pointer nonsense is still a bit alien to me.
typedef bool (*winbeeptype)(unsigned int); is like the prototype of the function, so winbeeptype is type with 1 argument (an unsigned int) and a return type of bool, the same as MessageBeep from the DLL. win32_beep is created from this type:winbeeptype win32_beep; Finally the function pointer is asked for providing DLL handle and function name and squeezed into the winbeeptype prototype and it is assigned to win32_beep.win32_beep = (winbeeptype) wxDllLoader::GetSymbol(mydll, "MessageBeep"); |
9. Re: Load DLL Failed? #2722 |
Hi, Need time to be understand.. >_< How do we know winbeeptype win32_beep ? Thank you.Meow~ |
10. Re: Load DLL Failed? #2723 Posted by: 2003-10-09 20:44:19 |
I'm not sure I know which bit, you don't get, I'll write another example:
wxDllType mydll = wxDllLoader::LoadLibrary("libname");
typedef int (*int_func_int_int)(int, int);
int_func_int_int p_funk;
p_funk = (int_func_int_int) wxDllLoader::GetSymbol(mydll, "funk");
int result = p_funk(5,8); |
11. Re: Load DLL Failed? #2752 |
Hi Adam,
I am just back from outstation. So, how do we know the type of function from the dll for wx?
Thanks.Meow~ |
12. Re: Load DLL Failed? #2754 Posted by: 2003-10-17 23:13:09 |
Well in the first example I looked it up in the win32 docs, for the second I'm assuming we would know, because we had written it. Are you trying to use functions from a 3rd party DLL which you have no import docs or source? |
13. Re: Load DLL Failed? #2755 |
Hi, Hmm... Not really. Becuase, sometime i will download others dll from the internet, so that we do not know the type or function names...Meow~ |
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 |