Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9016217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:56:19+00:00 2026-06-16T03:56:19+00:00

In my previous question , I asked why I kept getting the error message

  • 0

In my previous question, I asked why I kept getting the error message bad DLL calling convention when trying to call functions from a DLL. The general consensus was that I needed to change the calling convention to cdecl. Makes sense.

Unfortunately, I cannot place it right there on the function declaration importation. I had to either “create a wrapper DLL” or “create a type library for the DLL.”

I am very unfamiliar with VB as my main focus at work is C# and this is the first time working in the language for a very long time. I’m not sure exactly how to accomplish this task.

I’m also confused as to how a wrapper DLL helps things. Supposedly I can’t decorate a function import with cdecl in my code but if I move that exact function import to a new VB6 DLL and then reference that DLL it suddenly works?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:56:20+00:00Added an answer on June 16, 2026 at 3:56 am

    I actually think this question was better on the topic.

    To sum up, you can “place it right there on the function declaration importation”, but the VB6 IDE doesn’t know how to debug such a thing. But the compiler deals with it just fine. Once you compile it into a dll then your main project can access the functionality that was compiled.

    Perhaps you are asking how to move these into a dll? If that is the case, you need to create a new Project of type “ActiveX Dll”. Name it something like PwrUSB. Next, add a class (or rename the default/empty one if it is provided) to something like PwrUSBApi. Next, in the properties window, set the class to GlobalMultiUse. In a module called MDeclares, drop in all of your declarations:

    'from your other post...
    Public Declare Function InitPowerDevice CDecl Lib "PwrDeviceDll.dll" (ByRef firmware() As Byte) As Long
    

    Back in your PwrUSBApi class:

    'forward your calls to the dll
    Public Function InitPowerDevice (ByRef firmware() As Byte) As Long
       InitPowerDevice  = MDeclares.InitPowerDevice(firmware)
    End Function
    

    You could create a more fully fledged object model from the API, but I’d start with this simple wrapper until you sort out all of the APIs.

    Oh yeah, back in your main project you’d add a reference your new wrapper PwrUSB.dll in the Project menu. Then in the code you would use it something like this:

    Dim numOfDevices as Long 
    Dim firmware() As Byte
    Redim firmware(0 to 31)
    numOfDevices = PwrUSB.InitPowerDevice(firmware)
    

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from a previous question i asked, I'm now trying to figure out
This stems from a previous question I asked - about a write conflict with
From the previous question I asked, I am still having the same question. I
From the previous question I asked, RemoveAll is the cleanest way to remove from
I got http://jsfiddle.net/8p2Wx/2/ from a previous question I asked and I see these lines:
In a previous question I asked how to implement a client side bad word
This stems from a previous question I asked regarding code metrics. I have been
This is a separate problem lingering from a previous question I asked here on
The previous question I asked about creating a DIV where size is calculated from
From a previous question I asked (http://stackoverflow.com/q/13383552/740318) I came full circle from creating a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.