Click here to Skip to main content
13,089,610 members (59,335 online)
Rate this:
Please Sign up or sign in to vote.
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 14-Feb-13 3:25am
Updated 14-Feb-13 3:41am
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

Rate this: bad
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.

extern "C"
  __declspec( dllexport ) int AVitalFunction( int iParameter )
   //do important things...
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2017
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