...

View Full Version : [VB6] - Program Files Variable?



jacksont123
10-07-2007, 04:37 PM
Is there a variable I can use in a string for Program Files?

sage45
10-07-2007, 11:25 PM
The %programfiles% variable at the DOS level will give you the program files directory. If your dealing with an x64 Windows Operating system you also want to look for an x86 Program Files directory.


Dim i as Integer
Text1.Text = ""
i = 1
While Environ$(i) <> ""
Text1.Text = Text1.Text + Mid(Environ$(i), 1, InStr(1, Environ(i), "=") - 1) + vbNewLine
i = i + 1
Wend
Provides the environment variables on a particular system.

To actually assign an environment variable to a variable in your application you would use:
dim strProgramFile as string
strProgramFile = Environ(”ProgramFiles”)

Here is a link that tells another technique to use: http://vbtechniques.com/content.asp?a=co&cID=624

-saige-



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum