Using variable for "libname" in Declare statement for DLL function

Brooks.Wait

New Member
Joined
May 11, 2011
Messages
2
I am trying to declare a dll function in VB6.

The syntax for a Declare statement is as follows:
[Public | Private] Declare Function name Lib "libname" [Alias "aliasname"] [([arglist])] [As type]

I will not know the name of the dll until run time. So, at run time I read the dll name into a string variable and try to pass it to the "libname" portion of the Declare statement above. Is there anyway to do this? When I try to do this I get a compile time error. I am using VB 6.

Any help is greatly appreciated! Thanks!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Perhaps you could use instead something like ...

Code:
libName = "Bob"
Application.Run libName & ".functionName"
 
Upvote 0
Well, I can't make that work ATM, so never mind.

Why do you not know the name of the dll until runtime?
 
Upvote 0
Take a look at the LoadLibrary,GetProcAddress, Freelibrary and CallWindowProc APIs.However, working with APIs that have string argument buffers is difficult.

Take a look here where it is discussed
 
Upvote 0

Forum statistics

Threads
1,215,497
Messages
6,125,158
Members
449,208
Latest member
emmac

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top