Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
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 14-Feb-13 3:25am
Edited 14-Feb-13 3:41am
v2
Comments
Sandeep Mewara at 14-Feb-13 9:37am
   
If I say 'Yes' then? I doubt if you are just looking for Yes-No answer or more?
YourAverageCoder at 14-Feb-13 9:42am
   
I updated the question based on your response. I hope it is more clear now.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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...
  }
 
}
  Permalink  
Comments
YourAverageCoder at 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 at 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)



Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100