Dynamically set PATH variable in application
-
I have this situation where I have to dynamically set the PATH variable used by the application. Imagine I have 2 versions of mylib.dll: c:\version1.0\mylib.dll c:\version1.1\mylib.dll My PATH variable is c:\version1.1; c:\version1.0 Now, my application links to mylib.lib, so whenever I startup my application, it is looking for the mylib.dll based on my PATH settings. What I want to accomplish is to give the user the possibility to specify which version of the dll is going to be used by the application (via a dialog box). So I thought the solution was to overrule the default PATH variable used by the application by my own one (c:\version1.0\mylib.dll needs to be used). Is this possible? How to accomplish this? Thanks in advance Wim
-
I have this situation where I have to dynamically set the PATH variable used by the application. Imagine I have 2 versions of mylib.dll: c:\version1.0\mylib.dll c:\version1.1\mylib.dll My PATH variable is c:\version1.1; c:\version1.0 Now, my application links to mylib.lib, so whenever I startup my application, it is looking for the mylib.dll based on my PATH settings. What I want to accomplish is to give the user the possibility to specify which version of the dll is going to be used by the application (via a dialog box). So I thought the solution was to overrule the default PATH variable used by the application by my own one (c:\version1.0\mylib.dll needs to be used). Is this possible? How to accomplish this? Thanks in advance Wim
Could you dynamically link to the DLL and use LoadLibrary() to specify the path for the DLL? Systems AXIS Ltd - Software for Business ...
-
Could you dynamically link to the DLL and use LoadLibrary() to specify the path for the DLL? Systems AXIS Ltd - Software for Business ...
-
I have this situation where I have to dynamically set the PATH variable used by the application. Imagine I have 2 versions of mylib.dll: c:\version1.0\mylib.dll c:\version1.1\mylib.dll My PATH variable is c:\version1.1; c:\version1.0 Now, my application links to mylib.lib, so whenever I startup my application, it is looking for the mylib.dll based on my PATH settings. What I want to accomplish is to give the user the possibility to specify which version of the dll is going to be used by the application (via a dialog box). So I thought the solution was to overrule the default PATH variable used by the application by my own one (c:\version1.0\mylib.dll needs to be used). Is this possible? How to accomplish this? Thanks in advance Wim
Wim Jans wrote: So I thought the solution was to overrule the default PATH variable used by the application by my own one (c:\version1.0\mylib.dll needs to be used). Is this possible? How to accomplish this?
SetEnvironmentVariable()
comes to mind.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
I have this situation where I have to dynamically set the PATH variable used by the application. Imagine I have 2 versions of mylib.dll: c:\version1.0\mylib.dll c:\version1.1\mylib.dll My PATH variable is c:\version1.1; c:\version1.0 Now, my application links to mylib.lib, so whenever I startup my application, it is looking for the mylib.dll based on my PATH settings. What I want to accomplish is to give the user the possibility to specify which version of the dll is going to be used by the application (via a dialog box). So I thought the solution was to overrule the default PATH variable used by the application by my own one (c:\version1.0\mylib.dll needs to be used). Is this possible? How to accomplish this? Thanks in advance Wim
Look at the "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" entry in Registry. It's the modern approach now. You may use it for your purpose. For example, HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\someserver.exe @="S:\SRV7\Run\Release\bin\someserver.exe" "Path"="S:\SRV7\Run\Release\bin\;S:\SRV7\Run\Release\dll\" NOTE There is the separator ";" between pathes. With best wishes, Vita