If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
palikem
Experienced Solver
Posts: 69 Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko
Post
by palikem » Sat Nov 04, 2017 11:30 am
Hi everybody.
What am I doing wrong.
Code: Select all
static const wxChar *LIB_NAME = _T("MCP2210DLL-UMx86.dll");
wxDynamicLibrary dll;
dll.Detach();
dll.Load(LIB_NAME);
typedef void (*MyFunc)(unsigned int, unsigned int);
MyFunc myfunc = (MyFunc) dll.GetSymbol("DllInit");
myfunc(0x04D8, 0x00DE);
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Nov 04, 2017 12:34 pm
Impossible to tell from a distance. First you should add proper error checking to your code.
Check the return value of wxDynamicLibrary::Load(). If it's false, the DLL could not be loaded.
Check the return value of wxDynamicLibrary::GetSymbol(). If it's NULL, the function was not found in the DLL.
Use the source, Luke!
palikem
Experienced Solver
Posts: 69 Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko
Post
by palikem » Sat Nov 04, 2017 12:56 pm
I checked it.
everything is OK.
the program will start, reads dll and also a function.
when I use this feature, it stops responding
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Nov 04, 2017 1:14 pm
Create a debug build and check where exactly it crashes. If "myfunc" is not NULL and it crashes inside the function call, the parameters you're passing are wrong or there is a problem with the DLL itself.
Do you have any documentation for the DLL? I couldn't find anything with Google.
I found this though:
http://www.signal11.us/oss/hidapi/
Did you try that approach?
Use the source, Luke!
palikem
Experienced Solver
Posts: 69 Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko
Post
by palikem » Sat Nov 04, 2017 1:28 pm
hidapi i tried
Linker many mistakes.
I did not know how to remove it.
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Nov 04, 2017 3:10 pm
hidapi i tried
Linker many mistakes.
It worked almost out-of-the-box for me. Just add hid.c and hidapi.h to your project. And you need to add Setupapi.lib to your list of libraries. This library should come with the compiler.
Use the source, Luke!
palikem
Experienced Solver
Posts: 69 Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko
Post
by palikem » Sat Nov 04, 2017 3:51 pm
"Setupapi.lib" I did not find it
You are reporting this error.
Attachments
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sat Nov 04, 2017 4:57 pm
Sorry, i'm using Visual Studio only and there this line compiles fine.
Use the source, Luke!
PB
Part Of The Furniture
Posts: 4204 Joined: Sun Jan 03, 2010 5:45 pm
Post
by PB » Sat Nov 04, 2017 6:10 pm
FWIW, I could compile hid.c (hidapi 0.70) with MinGW32 (GCC 5.3) just fine (using CodeLite as testing IDE).
But the source code is different in the part where you reported the error.
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR) &msg, 0/*sz*/,
NULL);
palikem
Experienced Solver
Posts: 69 Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko
Post
by palikem » Sat Nov 04, 2017 7:25 pm
Thank you PB.
Fixed issue with HIDAPI.
The original problem with wxDynamicLibrary has not been resolved.
If someone has a good idea how to solve the original problem.
I will be grateful.
Attachments
palikem
Experienced Solver
Posts: 69 Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko
Post
by palikem » Sat Nov 04, 2017 7:31 pm
Thank you doublemax.
For Setupapi.lib.
Without it it would not work.
ONEEYEMAN
Part Of The Furniture
Posts: 7479 Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine
Post
by ONEEYEMAN » Mon Nov 06, 2017 3:15 pm
Hi,
So the program still crashing even after adding everything to your project?
Thank you.
palikem
Experienced Solver
Posts: 69 Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko
Post
by palikem » Mon Nov 06, 2017 7:12 pm
wxDynamicLibrary are no longer in use in the project.
The program always stops working and closes the.
I use HIDAPI as my doublemax advised me.