[program-l] VB6: How can I use a VC++6 DLL Installed in the Same Folder as the VB Application?

  • From: gerald.g.weichbrodt@xxxxxx
  • To: program-l@xxxxxxxxxxxxx
  • Date: Wed, 14 Sep 2005 10:59:36 -0400

The subject doesn't really do my question justice, so here's what I'm
really asking.

Let's suppose I write a VB program and package it, say, with either the
Visual Studio Installer or the Package and Deployment Wizard.  In this
case, I'd just about certainly using Visual Studio Installer, just in case
anybody wonders.  The important points are these:  I want the user to be
able to change the default install location for the program in case they
want to do so.  Further, I'd like to have the installer drop a little C DLL
into the program directory to do some low-level manipulation in memory
that's a little hard to do directly in VB.  To give access to the functions
in the C DLL, I'd stick a "Declare" statement for each function at the top
of my VB form.  This Declare statement needs to give a location for the DLL
holding each function.  For instance, one of my Declares might be something
like:

Private Declare Function UInt82Hex Lib "Type2Hex" Alias "uint82hex" (ByVal
InVal As Byte, ByVal OutVal As String) As String

My concern is about that clause 'Lib "Type2Hex"'.  If I give a complete
path to the DLL, then I run into trouble if the user decides to put the
application (and with it the DLL) into a different folder somewhere.  If I
don't give any path information, then it becomes uncertain, I think,
whether the DLL will be found at any given time based on what the computer
considers to be the current directory.  So is there any way I can make sure
the application's path will be used when my program tries to access the
DLL?

Thanks,
Jerry

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: