Home > Software engineering >  [for] VC6 call third-party DLL file, c.
[for] VC6 call third-party DLL file, c.

Time:10-31

DLL file is located in the project root directory, the following structure

~/DLL, the DLL home folder
- the dir1-name -- DLL folder 1
- dir2 -- DLL folder 1
- dir3 -- DLL folder 1
. - the DLL files and other files, main entrance DLL file here
.
.
/INCLUDE - head folder
/LIB, LIB folder

A link between the DLL, now need to use vc6 calls, require the use of relative paths, you know how great god? Just contact the JNI soon, thank you

CodePudding user response:

Can get first program the absolute path and folder name form the invocation path

CodePudding user response:

VC 6 can be added inside the LIb and h file
Then compiled into the relevant DLL

CodePudding user response:

Relative path is displayed links LoadLibrary GetProcAddress call FreeLibrary

CodePudding user response:

Procurement procedures of absolute path, combined with the corresponding DLL folder name form the invocation path, using LoadLibrary way

CodePudding user response:

reference zgl7903 reply: 3/f
relative path is displayed links LoadLibrary GetProcAddress call FreeLibrary

Because it is the third party to provide DLL LoadLibrary so they said this way is not
Can only use implicit call,

CodePudding user response:

reference 1st floor u013527739 response:
to get the program of absolute path and folder name form the invocation path

In my project directory structure is the release into the DLL folder, inside put DLL files and subfolders, this can do

CodePudding user response:

DLL needs in EXE can load position, general EXE directory is loaded by default directory, a folder directory will find load DLLS

CodePudding user response:

Then try to use GetEnvironmentVariable and the SetEnvironmentVariable add DLL path to "of" the path environment variable

CodePudding user response:


Platform SDK: DLLs, the Processes, and Threads
Dynamic - the Link Library Search Order
Starting with Windows XP, the dynamic - link library (DLL) search order 2 by the system depends on the setting of the registry key HKLM \ system \ CurrentControlSet \ Control \ Session Manager \ SafeDllSearchMode value.


Windows Server 2003: The default value is 1.
Windows XP: The default value is 0.
If SafeDllSearchMode is 1, the search order is as follows:

The directory from which The application The loaded.
The system directory. Use The GetSystemDirectory function to get The path of this directory.
The 16 - bit system directory. There is no function that obtains The path of this directory, but it is searched.
The Windows directory. Use The GetWindowsDirectory function to get The path of this directory.
The current directory.
The directories that are listed in The PATH environment variable.
If SafeDllSearchMode is 0, the search order is as follows:

The directory from which The application The loaded.
The current directory.
The system directory. Use The GetSystemDirectory function to get The path of this directory.
The 16 - bit system directory. There is no function that obtains The path of this directory, but it is searched.
The Windows directory. Use The GetWindowsDirectory function to get The path of this directory.
The directories that are listed in The PATH environment variable.

Alternate Search Order

The LoadLibraryEx function supports an alternate search order if The call specifies LOAD_WITH_ALTERED_SEARCH_PATH and The lpFileName parameter specifies a path. If SafeDllSearchMode is 1, The alternate search order is as follows:

The directory specified by lpFileName.
The system directory. Use The GetSystemDirectory function to get The path of this directory.
The 16 - bit system directory. There is no function that obtains The path of this directory, but it is searched.
The Windows directory. Use The GetWindowsDirectory function to get The path of this directory.
The current directory.
The directories that are listed in The PATH environment variable.
If SafeDllSearchMode is 0, the alternate search order is as follows:
The directory specified by lpFileName.
The current directory.
The system directory. Use The GetSystemDirectory function to get The path of this directory.
The 16 - bit system directory. There is no function that obtains The path of this directory, but it is searched.
The Windows directory. Use The GetWindowsDirectory function to get The path of this directory.
The directories that are listed in The PATH environment variable.
Note that the standard search strategy and the alternate search strategy differ in just one way: the standard search begins in the calling application 's directory, and the alternate search begins in the directory of the executable module that LoadLibraryEx is loading.

If you specify the alternate search strategy and its behaviors continues until all associated executable modules have had been located. After the system starts processing DLL initialization routines, the system reverts to the standard search strategy.


Legacy Search Order

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull