The program stopped working

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.
Post Reply
palikem
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

The program stopped working

Post by palikem »

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);
    
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: The program stopped working

Post by doublemax »

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
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: The program stopped working

Post by palikem »

I checked it.
everything is OK.
the program will start, reads dll and also a function.
when I use this feature, it stops responding
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: The program stopped working

Post by doublemax »

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
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: The program stopped working

Post by palikem »

hidapi i tried
Linker many mistakes.
I did not know how to remove it.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: The program stopped working

Post by doublemax »

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
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: The program stopped working

Post by palikem »

"Setupapi.lib" I did not find it

You are reporting this error.
Attachments
wxDevCpp.jpg
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: The program stopped working

Post by doublemax »

Sorry, i'm using Visual Studio only and there this line compiles fine.
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: The program stopped working

Post by PB »

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
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: The program stopped working

Post by palikem »

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
obr.jpg
palikem
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: The program stopped working

Post by palikem »

Thank you doublemax.

For Setupapi.lib.
Without it it would not work.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: The program stopped working

Post by ONEEYEMAN »

Hi,
So the program still crashing even after adding everything to your project?

Thank you.
palikem
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: The program stopped working

Post by palikem »

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.
Post Reply