Sign in to follow this  
Pengoose

Locating Program Files directory

Recommended Posts

I am trying to add some code that will look in a specific folder, inside a users Program Files directory for an installation program. Is there a specific function and/or a registry entry that I can use to locate a users Program Files folders, as some users may use a different drive letter than the standard "C:" drive when installing Windows? Any help is appreciated.

Share this post


Link to post
Share on other sites
Why would you look there for an installation program? If you mean an installed program, which program? Any usable program allows you to select the installation directory (when it needs installation), so just checking random places on the HD isn't likely to be very useful.

If you explain what it is that you are really trying to do, there are probably much better ways of doing it.

Share this post


Link to post
Share on other sites
this was a pain to get going, but this seems to work well:


#include <windows.h>
#include <shlobj.h>
#include <stdio.h>

int main()
{
char buffer[256];
SHGetSpecialFolderPath(NULL, buffer, 0x0026, 0);
printf("%s\n", buffer);
return 0;
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this