Re: Variable path to library?
- From: Cory <Cory@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 24 Jun 2008 14:58:00 -0700
Yup. Specifically this Declare statement calls the Calc_Lat_Long function
from Geo32.dll which is a file associated with a mapping program. The
program may not be installed in the same place on every computer since
several entities are going to be using it. The declare statement that I have
so far is:
Private Declare Function GEO_calc_lat_lon Lib "c:\PFPS\system\Geo32.dll"
Alias "CalcLatLong" (ByVal MGRS As String, ByVal Datum As Integer, ByRef
Latitude As Double, ByRef Longitude As Double) As Integer
I tried Lib PFPSPath & "\system\Geo32.dll" where PFPSPath is a Global
variable that is filled with the value of a registry entry that contains the
PFPS root folder path. If there were a way to dynamically change the actual
string that follows the lib I don't know it.
Cory
"Karl E. Peterson" wrote:
Cory wrote:.
I am Declaring a function from an external library that exists in different
directories on a number of users computers.
I take it, by that, that you are really doing what you say you are? That is,
writing a Declare for it, like you might SendMessage or any other standard DLL call?
That this isn't an ActiveX library, from which you are creating OLE objects, like
FSO and such?
I have successfully found the
programs directory entry in the registry and I can pull that value, but it
does not look like I can specify the path to the library in the declare
statement with a variable (the path). Anyone know a way around this?
Yes. Write the Declare without a path. The next step depends on how often you need
to call the library. If just once, you can change to the library folder, make the
call, and change back...
' Store current directory, to switch back to later.
' Switch to path that OE is installed in.
StartDir = CurDir()
ChDrive Path
ChDir Path
' Just for kicks, make sure we can load library and find procaddr.
If Exported(LibraryFile, FunctionName) Then
Call FunctionName(&H3F&, Dummy, 1)
Success = True
End If
' Restore former drive/path
ChDrive StartDir
ChDir StartDir
See http://vb.mvps.org/samples/project.asp?id=MultiOE for an example that does this
to start multiple instances of Outlook Express.
Another approach, if you need to call the function repeatedly, would be to load the
library explicitly (using LoadLibrary) prior to calling any functions in it. Again,
no path required in your Declare, but of course you will need to point directly at
the desired file in the LoadLibrary call.
--
..NET: It's About Trust!
http://vfred.mvps.org
- Follow-Ups:
- Re: Variable path to library?
- From: Karl E. Peterson
- Re: Variable path to library?
- References:
- Variable path to library?
- From: Cory
- Re: Variable path to library?
- From: Karl E. Peterson
- Variable path to library?
- Prev by Date: Re: Help Sendkeys
- Next by Date: Re: Variable path to library?
- Previous by thread: Re: Variable path to library?
- Next by thread: Re: Variable path to library?
- Index(es):
Relevant Pages
|