C ++ moves dll files from root folder to subfolder

I am making a program in Visual C ++. The program relies on some DLL files that I do not want to host in system32. Now the dll files are in the same folder as my .exe, but I would like to move them to a subfolder. The problem is that if I move files, my application does not start and comes up with this error message:


MyProgram.exe - Cannot Find Component

This application failed to start because myDll.dll was not found. Reinstalling the application may fix the problem.


I had the same problem before, where if I could find a solution that included adding something to the registry, but I forgot how it works, and now I can no longer find the manual.

Can anyone help me out?

+4
source share
3 answers

I believe this is the article you are looking for:

http://www.codeguru.com/Cpp/WP/dll/article.php/c99

Each application can now store its own registry path under the following key:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Application Paths

Use the application path, set the key for your application using ONE.EXE from the above example:

HKEY_LOCAL_MACHINE ... \ CurrentVersion \ Application Paths \ ONE.exe

Set the default value for the full path to the executable, for example:

C: \ Program Files \ ONE \ ONE.exe

Add a subkey called Path

0
source

There are several ways to solve this problem. As already mentioned, you can change the search path for your application in the registry. Sometimes you do not have write permissions to the registry or you cannot do this for other reasons, then you can explicitly set the path to the dll, for this the WinAPI function is SetDllDirectory , see MSDN .

+3
source

It looks like you are after the key HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ App Paths . See here for full details. In short, a string named Path points to a DLL search path. For example, if your application was called "MyApp", a .reg file like this might do the trick:

 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppPaths\MyApp.exe] @="C:\\Program Files\\MyCompany\\MyApp\\MyApp.exe" "Path"="C:\\Program Files\\MyCompany\\MyApp\\DLLs" 
+1
source

Source: https://habr.com/ru/post/1339217/


All Articles