We help IT Professionals succeed at work.

Where's the program dir?

jexd99
jexd99 asked
on
267 Views
Last Modified: 2010-04-04
Hi,

   I want to get the program files directory. There doesn't seem to be a getprogramdir or an api command which retrieves this info (similiar to accessing the windows directory). Should this be retrieved somewhere in the registry, or is there an api command I should be using to retrieve this?
              Thanks
Comment
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Commented:
Well, you can use GetDir at the moment your program is started.
GetDir procedure returns the current directory; i guess jexd99 needs the "ProgramDir" (e.g. C:\Programs).
GetDir is not proper cause, for example, if you activate a shortcut of the program which is stored in another directory, usually in the Desktop directory, then this is the directory you will get and not the correct location of the exe file.So, julio is correct.

Commented:
Hohoho, just a sugestion, don't shoot me. I julio is right, but what if you're making a program for Win3.11
Don't know :) I've never worked in Win3.11.

Commented:
Yeah, Win3.11, some customers still use it. Damn difficult to make two versions of your program, win3.11 and 95/NT.
By the way, In the previous comment I meant : I know that julio is right (forgot the KNOW). This for don't getting the wrong idea. See you!
I'm not a Windows expert, still guess it's a mess to do this job in Win3.11 because Win3.11 has not the concept of ProgramFilesDir itself; in general, if you plan a Win3.11 program, you should "think" win3.11 in order not to get in troubles.

Anyway, just my opinion.
I think, In Win3.11 you should look in one of the windows ini files,if the program was installed properly.

Commented:
Hi Ronit, correct. But you still have to know the place of that ini file. And who says that the user has installed windows in the windows\ directory?
Then, In 16bit you first call the GetWindowsDir.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.