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

  • From: David Lant <david.lant@xxxxxxxxxxxx>
  • To: "'program-l@xxxxxxxxxxxxx'" <program-l@xxxxxxxxxxxxx>
  • Date: Wed, 14 Sep 2005 16:56:40 +0100

Hi Jerry,

AS your library name is enclosed in quotes, could you not simply concatenate
it with App.Path into a string value?  Or does the library name have to be a
literal?  Would Lib App.Path & "Type2Hex" work?

David Lant

I.T. Consultant 
Consultancy & Development
ICT Services
Tel: (01392) 382464

Devon County Council accepts no legal responsibility for the contents of
this message. The views expressed do not reflect those of Devon County
Council.


-----Original Message-----
From: gerald.g.weichbrodt@xxxxxx [mailto:gerald.g.weichbrodt@xxxxxx] 
Sent: 14 September 2005 16:00
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] VB6: How can I use a VC++6 DLL Installed in the Same
Folder as the VB Application?



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
** 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: