入門級程式員,第一次用VS2010在仿照廠家Demo寫了一個MFC 應用程式,可是要呼叫廠家提供的dll 元件,在環境配置選擇Use MFC in a Shared DLL之后編譯無出錯,拉到一臺沒有裝VS的電腦上運行,會出現各種缺失MFC1000.dll之類的需要配置動態庫的問題
問題就說:我怎么又能再呼叫廠家dll或者lib檔案的同時,又在其他沒裝軟體的電腦上獨立運行(只在同一檔案夾內放入了廠家提供的dll檔案的那種,而不是把各種亂七八糟的dll都加入到電腦C盤system下安裝)?需怎么配置環境
uj5u.com熱心網友回復:
"Use MFC in a Shared DLL之后編譯無出錯,拉到一臺沒有裝VS的電腦上運行,會出現各種缺失MFC1000.dll"工程設定 "Use MFC in a Static Library" 就不會 呼叫 MFC 的 動態 MFC1000.dll 庫
uj5u.com熱心網友回復:
自己做個安裝程式,用到什么DLL就復制到安裝目錄下就行了(MFC的也不例外)。Windows是默認在你的exe目錄下找DLL的,你的exe目錄下找不到才會去找system32。MFC的DLL微軟有做安裝程式,想偷懶的話也可以直接在安裝程式里直接運行VCRedist_x86.exe、 VCRedist_x64.exe或者VCRedist_arm.exe。
只有目標系統自帶的DLL不需要包含在安裝程式里。例如你寫Word自動化程式,用戶沒有裝Word你的程式就跑不起來,這不是你的問題。
uj5u.com熱心網友回復:
Dynamic-Link Library Search OrderA system can contain multiple versions of the same dynamic-link library (DLL). Applications can control the location from which a DLL is loaded by specifying a full path, using DLL redirection, or by using a manifest. If none of these methods are used, the system searches for the DLL at load time as described in this topic.
Standard Search Order
The dynamic-link library (DLL) search order used by the system depends on whether 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, create the HKLM\System\CurrentControlSet\Control\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 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 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 versions of Windows prior to the ones listed at the beginning of this section do not support SafeDllSearchMode. For more information, see Legacy Search Order below.
Alternate Search Order
The standard search order used 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, its behavior continues until all associated executable modules have 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.
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 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 this does not include the per-application path specified by the App Paths registry key.
The SetDllDirectory function supports an alternate search order if the lpPathName parameter specifies a path. The alternate search order is as follows:
The directory from which the application loaded.
The directory specified by lpPathName.
The system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is System32.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is System.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The directories that are listed in the PATH environment variable.
If the lpPathName parameter is an empty string, the call removes the current directory from the search order.
SetDllDirectory effectively disables safe DLL search mode while the specified directory is in the search path. To restore safe DLL search mode based on the SafeDllSearchMode registry value and restore the current directory to the search order, call SetDllDirectory with lpPathName as NULL.
Legacy Search Order
Versions of Windows earlier than the ones listed under Standard Search Order do not support the SafeDllSearchMode value. The DLL search order is as follows:
The directory from which the application 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.
See Also
Dynamic-Link Library Redirection
LoadLibrary
LoadLibraryEx
SetDllDirectory
Side-by-side Components
Send comments about this topic to Microsoft
Build date: 8/15/2007
uj5u.com熱心網友回復:
Use MFC in a Shared DLL意思是動態呼叫微軟MFC的dll,即MFC1000.dll之類的,和你要呼叫的廠家dll沒關系。你可以Use MFC in a Static Library,這樣vs會把MFC dll靜態連接到你的exe中(exe會變大)
也可以看客戶機提示缺啥dll,就去你的vs安裝目錄拷貝出來一起,放在exe目錄中一起交給客戶,應該沒幾個dll
uj5u.com熱心網友回復:
做個安裝包就可以,寫不寫C盤都是你說了算轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/67060.html
標籤:進程/線程/DLL
上一篇:linux udp socket如何不等包,立馬發送一個包?
下一篇:MFC問題,請教各位
