The path for the esri_odma.dll is based on registry entries and could be
different on every client machine. I'm trying to find out how I can modify
the Declare Function statement to take a variable for the DLL path. Any
input would be greatly appreciated. Thanks.
"john franklyn" <john.f...@bentley.com> wrote in message
news:e1Pk0Kt6BHA.2276@tkmsftngp03...
'***and before you call that DLL use
Declare Function LoadLibrary Lib "kernel32" Alias _
"LoadLibraryA" (ByVal _
lpLibFileName As String) As Long
strDir = somequalifiedpath to your dll
lngVal = LoadLibrary(strDir & "esri_odma.dll")
'0 on error... if 0 check Err.LastDllError
'***before you end the program use
Declare Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) _
As Long
lngVal = FreeLibrary(strDir & "esri_odma.dll")
Give that a try..... I'm pretty sure that'll work.......
Mike
"john franklyn" <john.f...@bentley.com> wrote in message
news:e1Pk0Kt6BHA.2276@tkmsftngp03...
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Declare it ~without~ the path in the lib argument. That way the system
will use it's standard search rules for lib loading, which are:
1. The directory from which the application loaded. (i.e. App.Path)
2. The current directory.
3. The system directory.
4. (NT) only: The 16-bit system directory.
5. Windows directory.
6. Directories that are listed in the PATH environment variable.
Rule #2 can cover a situation like you describe. VB loads libraries
when you make the first call to one of the declared methods. Retreive
the path from the registry and immediately before making the first
call, simply ChDrive and ChDir to that path. VB keeps libs loaded
until the app terminates, so once it's loaded you can restore/change
the current drive/dir as needed.
Alternatively you could call LoadLibrary yourself using the path
retreived from the registry. Note however it requires a complimentary
call to FreeLibrary when the app terminates in order to maintain the
lib usage counter.
-Tom
(please post replies to the newsgroup)
You absolutely, positively can't. If you specify a path in the declaration,
that's the ONLY place Windows will look for the DLL and you absolutely,
positively cannot change that path at runtime. If the file is not in that
exact folder, the function call will fail, even if the DLL is in a folder
that Windows would normally search. You should omit the path, and the DLL
just needs to be in a folder that is one of the paths that Windows will
automatically search.
With that said, you *could* get the path from the Registry and then modify
the Path environment variable in autoexec.bat to include that path (you will
likely have to create autoexec.bat on some systems). The system would then
have to be rebooted. This might be OK to do in a work environment WITH the
admin/supervisor's approval (if you're the admin, so much the better). I
definately wouldn't recommend it for any other situatuation.
Perhaps somebody else has a better "solution".
Mike
I never even thought of LoadLibrary (and I've even used that API function on
several occasions). Good call, even if you did make my reply look foolish.
<g>
Mike