Specifying DLL

R

Rita

I use a function in a DLL.

My declare is as follows:

Public Declare Function Func1 Lib "MyFuncs.dll" () As Long

This only works when my dll is placed in the "Default
database folder" (options, general). I can specify the
Default folder to be somewhere else - but a better
solution would be to specify the full path to MyFuncs.dll

Public Declare Function Func1 Lib "c:\sample\MyFuncs.dll"
() As Long

This - however - does not work....

What should I do?
 
D

Dan Artuso

Hi,
It should work if you have the full path as an argument to Lib
Here's an excerpt:

The Lib clause in the Declare statement tells Visual Basic where to find the .dll file that contains the procedure. When you're
referencing one of the core Windows libraries (User32, Kernel32, or GDI32), you don't need to include the file name extension:

Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long

For other DLLs, such as those created in Fortran, the Lib clause is a file specification that can include a path:

Declare Function lzCopy Lib "c:\windows\lzexpand.dll" (S As Integer, D As Integer) As Long

If you do not specify a path for libname, Visual Basic will search for the file in the following order:

Directory containing the .exe file

Current directory

Windows system directory (often but not necessarily \Windows\System or \winnt\System32)

Windows directory (often but not necessarily \Windows or \winnt)

Path environment variable
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top