LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I programmatically find Program Files directory?

Do I need to use the Windows Registry? If so, where is it in the registry?

I'm ultimately trying to find the Wordpad.exe file. I've been able to find where it's location is stored in the registry, but the location listed is relative to the Program Files directory. Thus, I must now find the Program Files directory, too.

Thanks in advance,
Derek
0 Kudos
Message 1 of 7
(7,224 Views)
A quick google search yielded the key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion]

with value Name: ProgramFilesDir.

___________________
Try to take over the world!
0 Kudos
Message 2 of 7
(7,202 Views)
Attached is a VI WINDOWS-FIND-ABSOLUTE-APPLICATION-PATH.VI

Given an application name in the regsitry such as WORDPAD.EXE this VI is intended to read all the necessary information from a Windows machine registry and return an absolute path.

The VI specifically checks first to ensure that it is operating on a Windows platform before proceeding to read any registry keys. I don't work with other platforms a great deal, perhasps someone would care to 'fill in the blanks'. Entrys in the registry for an application registration are either absolute or relative (I believe they should normally be relative to the %ProgramFiles% registry entry to allow system restoration to an alternative location).

I did this because I wonderd why the question had been posed. There are a number of especilly interesting things happen with respect to WORD and the way associated files are dealt with. However I imagine a scenario like this. I am running a nice fat VI with lots of demands on system resources and I want to open up a viewer application for an RTF file I have generated. I don't want WORD to open the files as its a great FAT application and has currently taken over the association for RTF files (despite it not being the registered handler in the registry - that's another story). Thus I want a lightweight application to do the work. Hence this VI.

If this does the job please let us all know.

Message Edited by Conseils on 04-16-2005 10:15 PM

Message 3 of 7
(7,198 Views)
Thanks Conseils,

That was exactly what I needed!!

Derek
0 Kudos
Message 4 of 7
(7,168 Views)

I just grabbed this vi, seems to be just what I need (only need the system default program files directory part).  I noticed my application was not working right in Europe because of different naming of this directory.  I hope this programmatic approach will deliver the same directory name that the installer used for a resource file I am getting.

I'll send it off the Germany and see if it does the trick.

Thanks!

0 Kudos
Message 5 of 7
(7,021 Views)
Just wanted to say thanks for the vi. 
0 Kudos
Message 6 of 7
(6,767 Views)

Thanks for the feed back and Kudos guys... Don't forget to say what you are using it for...

 

 

0 Kudos
Message 7 of 7
(6,751 Views)