Jump to content
  • Advertisement
Sign in to follow this  
nekobasu33

access to the INSTALLED programs on Windows? using Win32?

This topic is 4113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to find and list of all the programs installed on Windows using WIN32 and C++? If NOT, is there any alternative way in finding the installed program on Windows? Any help would be appreciated. Thank you in advance.

Share this post


Link to post
Share on other sites
Advertisement
Why on earth would you care?

The closest you can get would be to use SHGetFolderPath to get the location of the "Program Files" directory and grovel around under there but not all programs install themselves there and some stuff aren't really "programs" in the sense the end-user thinks about. You could also grovel around in the add/remove programs data in the registry but not all programs register themselves there.

It depends greatly what you mean by "install". I prefer to use apps that I can "install" via xcopy and don't go mucking around leaving turds pointing to themselves all over the system - are those apps "installed"?

Share this post


Link to post
Share on other sites
see this:
http://www.codeproject.com/system/installed_programs.asp

Also check contents for problems with that method.

Share this post


Link to post
Share on other sites
Where you look for programs really depends on what types of programs you are interested in. If you're interested in a list of programs that the user would recognize and use then you could (and probably should) enumerate the programs in the Start Menu. If you're looking to get a list of programs which can be removed then you should enumerate Add/Remove Programs as already suggested.

Note, however, that there is a difference.

For example, if you enumerate the Start Menu then you can find that the user had Word, Excel, and Powerpoint installed. If you enumerate Add/Remove Programs then you can only know that they have Office installed. Further, when enumerating the Start Menu you might pick up on some programs that dont have uninstallers.

As a secondary note, if you choose to go with enumerating the Start Menu then you should also be familiar with using IShellLink. If you want to handle Office (and others) gracefully you will also need to be familiar with MSI as you will most likely need to call MsiGetShortcutTarget() and MsiGetComponentPath().

Share this post


Link to post
Share on other sites
I am sorry for the confusion.
What I am trying to accomplish is to find and list the programs/applications that are installed, but commonly used by the user. They are in the start menu, for example, Word, Photoshop, Outlook, etc. I guess I was a little misleading by saying "all the program installed".

Antheus, I actually came across that code project website when I did research. However, I convert what they have to VS2005 and when I tried to compile and run the code, it crashed. And I have no idea how to fix the problem.

By the way, Colin Jeanne, I am not sure what you mean by "enumerating the Start Menu". Can you please give me an example or maybe a code snippets?
And your suggestion, is it using regular WIN32 or MFC or anything like that? because I don't have that much knowledge using MFC.


Thank you for all the input, guys. I really appreciate it.

Share this post


Link to post
Share on other sites
These two places in the registry may be of interest to you:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist
Google should be able to tell you plenty about them.

Share this post


Link to post
Share on other sites
Thank you.
I am assuming we can get the list of the file if we can get access to the "DisplayName" of the applications in the registry.

Do you have any good article I can use?
I found this online:
http://www.codersource.net/win32_registry_operations.html

Any tips and tricks on how to access the registry?
And is there any other alternative to find these application?
I will eventually need to find out the most and least used application on the computer. :)

[Edited by - nekobasu33 on June 29, 2007 11:57:35 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by nekobasu33
I will eventually need to find out the most and least used application on the computer. :)


You cannot do that, since that criteria doesn't exist. If someone has installed MS Office, but only uses Word, how often is MS Office used? And if they use word only, but only from browser, are they really using word?

And what about applications that get started automatically and stay resident? Like MySQL?

The criteria that Add/Remove panel offers is useless. In my case, Microsoft Visual Studio is labeled "rarely", yet I use it daily for 8+ hours for past 6 months. Then there's "Multiverse Client", which I have launched exactly once 7 months ago, and is labeled "frequently".

Just to save you time - you cannot find out frequency of use.

Share this post


Link to post
Share on other sites
Quote:
Original post by nekobasu33
By the way, Colin Jeanne, I am not sure what you mean by "enumerating the Start Menu". Can you please give me an example or maybe a code snippets?
And your suggestion, is it using regular WIN32 or MFC or anything like that? because I don't have that much knowledge using MFC.

I do believe then that enumerating the items in the Start Menu is the most correct as not all programs have registered uninstallers nor is it true that it is possible to map from the uninstaller to the program itself for those that do.

The Start Menu is just a folder on your system which contains (mostly) shortcuts. You can enumerate the objects in the Start Menu by using FindFirstFile(), FindNextFile(), etc. or via IShellFolder::EnumObjects() or whatever your file system enumeration preference is. To get the path to the Start Menu you have two options

1) If you only need your program to work on Vista and above, I recommend you use the SHGetKnownFolderPath() with FOLDERID_StartMenu.

2) Otherwise use SHGetFolderPath() with CSIDL_STARTMENU.

For each item that you find in the folders you will need to see if it is a .lnk file (if you're using FindFirstFile() and friends) or if it has the SFGAO_LINK property (if you're using IShellFolder). If it is then you create an IShellLink to the item to get information such as the actual path to the binary.

As for deciding which programs are the most frequently used and least frequently used, the Start Menu already does this. You dont have access to that information, but creating a program to do this is a bit redundant.

Share this post


Link to post
Share on other sites
I got the path to the windows programs in the Start menu. The path is in LPCTSTR type.

Here's the path:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs

However, I am still not quite sure how to enumerate the programs. How do you actually go into each folder?

When I did this:

WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(path, &FindFileData);


I got "Programs" as the result. Isn't it the current folder? How can I go into the "Programs" folder and iterate through?

Also, I need to find the .exe files, and since the files in the start menu programs are .lnk, which is Windows shortcut, how can I accomplish this? Is there a way I can get access to the file's properties to know that a particular file is an "Application" under "Target Type" (if you right click and go to properties)?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!