Home > Software engineering >  Use MFC in a Shared DLL
Use MFC in a Shared DLL

Time:09-23

Entry-level programmer, VS2010 in modelled on the first factory Demo wrote an MFC application, but to call the manufacturer to provide a DLL dynamic link library, configuration choice Use MFC in a Shared DLL in the environment after compiled without error, to run on a computer no VS, will appear all sorts of missing MFC1000. DLL such as need to configure the problem of dynamic library
Question: how can I call again manufacturer DLL or lib files at the same time, also install the software in other didn't run independently on the computer (only in the same folder DLL in the factory to provide the sort of, rather than add all at sixes and sevens DLL to the computer disk C system, the installation)? Should be how to configure the environment

CodePudding user response:

"Use the after the MFC in a Shared DLL compiled without error, to run on a computer no VS, will appear all sorts of missing MFC1000. DLL "
Project Settings "Use MFC in a Static Library" will not call MFC dynamic MFC1000. DLL Library

CodePudding user response:

What oneself do a setup program, use the DLL is copied into the installation directory is no exception (MFC), Windows is the default in your exe directory for a DLL, you exe directory to find will find system32,

MFC DLL Microsoft do installer, want to be lazy also can run directly in the installer directly VCRedist_x86. Exe, VCRedist_x64. Exe or VCRedist_arm. Exe,

Only the target system's built-in DLL doesn't need to include in the installer, you write the Word automation program, for example, the user can't run without Word your program, it's not your problem,

CodePudding user response:

Dynamic - the Link Library Search Order
A system can contain multiple versions of the same dynamic - link library (DLL). Applications can control the location from which A DLL is the loaded by specifying A full path, using DLL redirection, or by using A manifest. If none of these methods are 2, the system searches for A DLL at load time as described in this topic.

Standard Search Order
The dynamic - link library (DLL) search order 2 by The system depends on been safe DLL search mode is enabled or disabled.

Windows Vista, Windows Server 2003, and Windows XP SP2: Safe DLL search mode is enabled by default. To disable this feature, the create in registry key HKLM \ System \ CurrentControlSet \ Control \ the Session Manager \ SafeDllSearchMode registry value and set it To 0. Calling the SetDllDirectory function effectively disables SafeDllSearchMode while the specified directory is in the search path and changes the search order as described in this topic.
Windows XP and Windows 2000 SP4: Safe DLL search mode is disabled by default. To enable this feature, create the SafeDllSearchMode registry value and set it To 1.

If SafeDllSearchMode is enabled, 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. Note that this does not include The per - application PATH specified by The App Paths registry key.

If SafeDllSearchMode is disabled, 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. Note that this does not include The per - application PATH specified by The App Paths registry key.
Note that the versions of Windows the prior to the ones listed at the beginning of this section do not support SafeDllSearchMode. For more information, see's Legacy Search Order below.

Alternate Search Order
The standard search order 2 by The system can be changed by calling The LoadLibraryEx function with LOAD_WITH_ALTERED_SEARCH_PATH. The standard search order can also be changed by calling The SetDllDirectory function.

Windows XP/2000 and Windows 2000 Server: Changing the standard search order by calling SetDllDirectory is not supported until Windows XP SP1 and Windows Server 2003.

If you specify an 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.

The LoadLibraryEx function supports an alternate search order if The call specifies LOAD_WITH_ALTERED_SEARCH_PATH and The lpFileName parameter specifies an absolute path.

Note that the standard search strategy and the alternate search strategy specified by LoadLibraryEx with LOAD_WITH_ALTERED_SEARCH_PATH 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 SafeDllSearchMode is enabled, the alternate search order is as follows:


The directory specified by lpFileName.
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related