How reference standard DLL relative paths in VB

Author: Michael Zhao ([email protected])
http://www.cnblogs.com/userinterface/

a long time, think only reference standard function in the DLL with an absolute location. In fact, you can also use relative paths. Very simple, try it now.

1) the absolute path method
, such as your DLL file is located in c: \ testDLL \ debug \ testDLL.dll
In general, you need to make the following statement in VB
Declare Sub mytest Lib "c: \ testDLL \ dubug \ testDLL.dll" ( ByVal x As Long)
other one workaround is to testDLL.dll placed in the windows system directory, so that you can directly reference the file name. However, the need to file into the windows system directory, very uncomfortable!

2) the relative path method
Well, look at how we use relative paths
assume your DLL file is located in c: \ testDLL \ debug \ testDLL.dll , VB program located in the directory c: \ testDLL \ vbClient
you can make the following program in VB statement
declare Sub mytest Lib "../dubug/testDLL.dll" ( ByVal x As Long)
If you run your VB program directly, the system will prompt the error: can not find ../dubug/testDLL.dll.

In order to make the above statement to work, temporarily turn off your VB project. Then open the project file with a text editor (notepad, editplus, etc) (that is, the suffix is vbp guy)
usually vbp file consists of several components, such as my vbp has two parts
Type = Exe
Reference = * \ G { } # 2.0-C000-000000000046 00020430-0000-0000 # 0 # .. \ .. \ .. \ .. \ the WINDOWS \ System32 \ # Stdole2.tlb the OLE Automation
Form1 = the Form1.frm
Module1 = Module1; the Module1.bas
the Startup = "the Form1"
ExeName32 = "Make Project1.exe"
Command32 = ""
the Name = "Project1"
the HelpContextID = "0"
CompatibleMode = "0"
MajorVer. 1 =
MinorVer = 0
RevisionVer = 0
AutoIncrementVer = 0
ServerSupportFiles = 0
VersionCompanyName = "American Standard "


FavorPentiumPro ((TM)) = 0
CodeViewDebugInfo = 0
NoAliasing = 0
BoundsCheck = 0
OverflowCheck = 0
FlPointCheck = 0
FDIVCheck = 0
UnroundedFP = 0
the StartMode = 0
the Unattended = 0
the Retained = 0
ThreadPerObject = 0
MaxNumberOfThreads =. 1

[the MS the Transaction Server]
AutoRefresh =. 1

What you do is add a line DebugStartupOption = 0 for 1 in the first part MaxNumberofThreads =. In this way, vbp file would look like
. . . (In front of the same, is omitted)
ThreadPerObject = 0
MaxNumberOfThreads. 1 =
DebugStartupOption = 0

[the MS the Transaction Server]
AutoRefresh. 1 =

OK.That apos All you !! reopen engineering VB development environment and run. A miracle happened now!

Demo code

Reproduced in: https: //www.cnblogs.com/userinterface/archive/2005/03/23/124390.html

Guess you like

Origin blog.csdn.net/weixin_34221036/article/details/93668148