Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


API Calls without Declare Statements

Posted on 2003-03-04
Medium Priority
Last Modified: 2010-04-07
I just stumbled across this VB Class Module on freevbcode.com, its based on info from vbdotcom.com.  It maked use of a handful of API calls to make a class that can be used to call basicly any API.  I have several questions:
1. Are there any performance issues involved in doing things this way?
2. Are there stability issues?
3. Do this make debuggin any harder?  (It seems to handle "Entry Point" errors pretty well.)
4. It uses a ParamArray to to pass in the Params used by the API call.  How are ParamArrays handled by VB?  Are all of the elements typed as Variants?
5. According to the description on freevbcode.com this class makes it possible to call some previously uncallable functions.  This sound right?

Here is the link to the code:

I am looking for hard answers here, not "I think so"'s or "if i recall correctly"'s or even the coveted "should be".

If answers are given to different questions by different poeple then I will divide up the points as evenly as possible.  That works out to about 40 points a question.
Question by:Da_Weasel
  • 2
  • 2
LVL 28

Accepted Solution

AzraSound earned 800 total points
ID: 8066523
1) I imagine performance issues would be negligible.  Under the covers, Visual Basic calls LoadLibrary on DLLs you have declared at design time and shuffles the memory around to pass in the required parameters

2) Again, I think what you see with the above code is just the low level implementation of what VB is doing anyways

3) I doubt it, except for the issue I will mention at the end

4) Yes

5) Uncallable exported functions of DLLs?  I don't know about that.  How the class works in and of itself, yes.  I believe there is some very interesting "hack-like" code in that class that allows you to pull this off from VB.

The only issue is the one of [out] parameters of any dll.  The above will successfully return the value the function returns, if any.  However, some functions require you pass in a variable that gets filled with information in the DLL function call.  Getting at these values is a trick that the above class doesn't take into consideration, I don't believe.  It would require keeping track of the memory addresses of those variables when passed into the function, and pulling their values back in afterwards.

Author Comment

ID: 8066792
wonderful...I am emailing the author of the code now to ask them about the ByRef params now....will post any info I get from them.

AzraSound: Good answers, I was kinda interested in the 'hack-like' code too.  Looks like the author used API calls to manipulate stacks to emulate ASM in VB.  Thats about as hardcore as you can get with VB IMHO.
LVL 28

Expert Comment

ID: 8066840
The author of that code (expert name 'Ark' here at EE) is notorious for doing the "impossible" from VB.

Author Comment

ID: 8356674
sorry it took so long to award points, havn't visited the site in a while.....

Thanks for the help!

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question