Click here to Skip to main content
15,900,641 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi everybody.I need your help.I made a software that can only run if i install it on C Drive.But when i install in I: Drive or other directory my software don't run.Cause my software search comutilities.dll file on c:\windows\system32\comutilities.dll.
I set this command %systemroot%\system32\comutilities.dll but its not working.

so guys could you plz tell me How to Set the Path to registry for all drive.
My software developed on C#.

Regards
Sazeeb
Posted
Comments
Herman<T>.Instance 13-Aug-11 13:54pm    
why don't you set the dll in the global assembly cache?

To get the path to the system32 folder you can use the API GetSystemDirectory.
For .Net you can use the Environment.SystemDirectory property.

Once you get the system32 path, simply append the dll name to it.

However there is a defined search path for a DLL and it includes the system32 directory.
So your program must simply search for the DLL name without the path and it would be found.
Search Path Used by Windows to Locate a DLL[^]

By the way, the subject makes no sense and is totally unrelated to your question.
 
Share this answer
 
v2
No! Don't try to find a work-around. It's merely a bug.

Look through your application and make sure you never use any hard-coded path names. There is not situations when such names could be useful. You cannot also rely on the working directory, as it totally depends on how the user loads your application. The user can do it from any directory.

All path names can only be calculated in run-time based on application's main executable module (for read-only files only) or relative to this path or relative to one of special directories, see System.Environment.GetFolderPath(System.Environment.SpecialFolder), http://msdn.microsoft.com/en-us/library/system.environment.aspx[^].

To find the application's executable path use this:
C#
string exePath =
    System.Path.GetDirectoryName(
        System.ReflectionAssembly.GetEntryAssembly().Location);


Also, path names could be stored in input data files (such as application settings); but then the content of such files should be tuned on installation.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900