Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. My question is whether you can make a USB communication DLL with C++ without exporting classes and just using static methods or not. If so then provide an example with code or link please. Thanks.
Posted
Updated 14-Feb-13 3:41am
v2
Comments
Sandeep Mewara 14-Feb-13 9:37am    
If I say 'Yes' then? I doubt if you are just looking for Yes-No answer or more?
YourAverageCoder 14-Feb-13 9:42am    
I updated the question based on your response. I hope it is more clear now.

1 solution

Yes you can export just functions and no classes but that's really the 'C' way not the C++ way. Are you having trouble importing the classes into the client or exporting them from DLL? anyway here's a 'C' style function export from a C++ Windows DLL interface.

//Myfile.cpp

extern "C"
{

  __declspec( dllexport ) int AVitalFunction( int iParameter )
  {
   //do important things...
  }

}
 
Share this answer
 
Comments
YourAverageCoder 14-Feb-13 9:51am    
I tried C++ style class exporting but setupapi.dll functions kept giving me Runtime Check Failure 0 even though i went through all function calls, kept them the same while trying both __cdecl and __stdcall. I just gave up on that. That's why i am asking if it's possible before resoring to classless C type approach.
Matthew Faithfull 14-Feb-13 10:06am    
A runtime check failure when calling API functions in Setupapi.dll is not related to how you choose to export your functionality from your DLL. Going over to a 'C' style interface on your code will not solve this problem. You don't have to worry overmuch about __cdecl vs __stdcall with API calls anymore unless you're going for Windows 2000 backward compatability. MS introduced some sort of bit twiddling magic which fixes things for you on the fly if you get it wrong many years ago. There must be something else wrong that's corrupting your stack before the call to into Setupapi.dll.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900