?
Solved

API Calls without Declare Statements

Posted on 2003-03-04
4
Medium Priority
?
159 Views
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:
http://www.freevbcode.com/ShowCode.Asp?ID=1863

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.
0
Comment
Question by:Da_Weasel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
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.
0
 
LVL 3

Author Comment

by:Da_Weasel
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.
0
 
LVL 28

Expert Comment

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

Author Comment

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

Thanks for the help!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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 Month15 days, 17 hours left to enroll

741 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