Enumerate applications installed on windows in C++ - c++

I Want to list all the installed applications in c. We can do it using two ways.
1. Using Uninstall registry and 2. WMI and Win32_product class.
But is it reliable using registry for enumerating installed product? Also WMI only lists product installed through MSI installer? is there another way to do it? if not which is the best and recommended way?

Your intuitions are correct, iterating the registry is the most complete way to find out which programs are 'installed'. Obviously this will not find stand-alone binaries/applications which do not register themselves with the windows registry.
See WMI "installed" query different from add/remove programs list?
Rob Haupt's Answer links to some code for inspecting the registry

Related

Where is the Increment method on the DataCache?

I want to use the Increment method from the DataCache documentation but the method is not available on my DataCache object. Clearly I don't have the version of Microsoft.ApplicationServer.Caching.Client.dll that matches the documentation but I can't seem to figure out what version contains that method and where to get the assembly???
The version I have 1.0.4632.0
I am using the AppFabric for Windows 1.1.
This method is part of Azure and not Windows Server. AppFabric exists in two versions : one for Windows Server and one for Azure. There are only a few differences (here is one of them).
If you're targeting Azure, simply add the package Microsoft.WindowsAzure.Caching. You will find a detailed introduciton here.
It you're targeting Windows Server, do it by yourself !

Which is the most appropriate way to find if a specific software is installed in Windows, using C++?

I'm writing a software that in a given moment needs to find if a given software is already installed (by its name) - so the same thing a installer does when it's going to installad its software and sometimes allerts that that software is already installed in the PC.
The problem is that I don't know which would be a good way of doing this. Now the softwares just looks to the default folder and if its unable to find the .exe, he then asks for the user to point out where he installed the software or else consider it uninstalled.
But I would like it to do things by its own; it should be capable of finding if a software is installed without user inputs, and I'm not sure which would be an efficient way of doing this.
The only way I found now is to do the same thing Windows' Add/Remove Programs does: look at many registry entries and try to found it, but I think this would take too much unacessary time give the fact it would look in many places to find only one software.
So isn't there any other less costful option in C++?
Thanks,
Momergil
This depends entirely on how the thing you want to ask about is installed. If it's always installed from an MSI, you can read up on MSI and learn to call the API and/or read the registry to see if its unique ID is there.
If it's installed with 'unzip', there's no concise solution.
what you are looking for is a key path: a registry location that is uniquely tied to that software.
You have two options:
A Registry key that is always present only when the software is installed.
eg. HKEY_CURRENT_USER\Software\BitTorrent\uTorrent
Look at the unique Uninstall entry of that software at: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall &
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
You will always find a REG_SZ here titled DisplayName which is used as the title in "Add Remove Software" Control Panel extension.
MsiGetProductInfo might get you the information you need, if you used Windows Installer.
If you didn't, well, then there's your problem... it's there for a reason.

Scanning Local Windows System for Attached USB Devices Using C++

What is the best way to scan the local Windows system for attached USB devices using C++? I need to get a list of Vendor and Product IDs to match against the my device's IDs. If there is a way to scan for a specific VID/PID combination, that would be even better. My end goal is to retrieve the virtual COM port Windows has assigned to the device. If there's a way to do all that, it would be fantastic. As always, examples are much appreciated. Thanks.
This is pretty much an MSDN example of what you want:
http://msdn.microsoft.com/en-us/library/ff558728%28VS.85%29.aspx
It seems you'll need the WDK if you want to access this kind of functionality (every MSDN search I can think of suggests this).
I was able to resolve this by querying WMI for the needed information. Basically, I was able to start with Microsoft's example code, modify it a bit, and finally build it into my own class that does what I need.
http://msdn.microsoft.com/en-us/library/aa390423%28v=VS.85%29.aspx
This list of Computer System Hardware Classes was also helpful:
http://msdn.microsoft.com/en-us/library/aa389273%28v=VS.85%29.aspx
I used the WMI Code Creator to preview the results of what looked to be promising classes.
In the end I used the following:
Namespace: root\CIMV2
Class: Win32_SerialPort
Property: PNPDeviceID and DeviceID

Microsoft Exchange CDOEX in a clustered environment

We have a VS2005 native C++ application which connects to Exchange
server using CDOEX and CDOEXM to create and modify calendar entries
for multiple user folders. It's a command line utility which must be installed on the same server where the exchange server is installed. What is the correct procedure to use this
utility in a clustered environment? Any help would be appreciated.
Might I suggest you take a look at.
http://msdn.microsoft.com/en-us/library/aa373130%28VS.85%29.aspx
for general information on how failover clustering works.
But I would also like to point out that going forward ( ie exchange 2007 , 2010) you don't get CDOEXM. And Instead you will have to find some way of integrating with powershell instead. There are classes to explicitly run powershell scripting from inside a program, but they are C# so you either migrate all your code to C# or use some bastardized blend of IJW.

how-to: programmatic install on windows?

Can anyone list the steps needed to programatically install an application on Windows. Aside from copying the files where they need to be, what are the additional steps needed so that your app will be a first-class citizen in Windows (i.e. show up in the programs list, uninstall list...etc.)
I tried to google this, but had no luck.
BTW: This is for an unmanaged c++ application (developed in Qt), so I'd rather not involve the .net framework if I don't have to.
I highly recommend NSIS. Open Source, very active development, and it's hard to match/beat its extensibility.
To add your program to the Add/Remove Programs (or Programs and Features) list, add the following reg keys:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\PROGRAM_NAME]
"DisplayName"="PROGRAM_NAME"
"Publisher"="COMPANY_NAME"
"UninstallString"="PATH_TO_UNINSTALL_PROGRAM"
"DisplayIcon"="PATH_TO_ICON_FILE"
"DisplayVersion"="VERSION"
"InstallLocation"="PATH_TO_INSTALLATION_LOCATION"
I think the theme to the answers you'll see here is that you should use an installation program and that you should not write the installer yourself. Use one of the many installer-makers, such as Inno Setup, InstallSheild, or anything else someone recommends.
If you try to write the installer yourself, you'll probably do it wrong. This isn't a slight against you personally. It's just that there are a lot of little details that an installer should consider, and a lot of things that can go wrong, and if you want to write the installer yourself, you're just going to have to get all those things right. That means lots of research and lots of testing on your part. Save yourself the trouble.
Besides copying files, installation tasks vary quite a bit depending on what your program needs. Maybe you need to put an icon on the Start menu; an installer tool should have a way to make that happen very easily, automatically filling in the install location that the customer chose earlier in the installation, and maybe even choosing the right local language for the shortcut's label.
You might need to create registry entries, such as for file associations or licensing. Your installer tool should already have an easy way to specify what keys and values to create or modify.
You might need to register a COM server. That's a common enough action that your installer tool probably has a way of specifying that as part of the post-file-copy operation.
If there are some actions that your chosen installer tool doesn't already provide for, the tool will probably offer a way to add custom actions, perhaps through a scripting language, or perhaps through linking external code from a DLL you would write that gets included with your installer. Custom actions might include downloading an update from a specific Web site, sending e-mail, or taking an inventory of what other products from your company are already installed.
A couple of final things that an installer tool should provide are ways to apply upgrades to an existing installation, and a way to uninstall the program, undoing all those installation tasks (deleting files, restoring backups, unregistering COM servers, etc.).
I've used Inno Setup to package my software for C++. It's very simple compared to heavy duty solutions such at InstallShield. Everything can be contained in a single setup.exe without creating all these crazy batch scripts and so on.
Check it out here: http://www.jrsoftware.org/isinfo.php
It sounds like you need to check out the Windows Installer system. If you need the nitty-gritty, see the official documentation. For news, read the installer team's blog. Finally, since you're a programmer, you probably want to build the installer as a programmer would. WiX 3.0 is my tool of choice - open source code, from Microsoft to boot. Start with this tutorial on WiX. It's good.
The GUI for innosetup (highly recommended) is Istool
You can also use the MSI installer built into Visual Studio, it's a steeper learning curve (ie is a pain) but is useful if you are installing software in a corporate environment.
To have your program show up in the Start program menu,
You would need to create folder
C:\Documents and Settings\All Users\Start Menu\Programs
and added a short cut to the program you want to launch.
(If you want your application be listed
directly in the Start menu, or in the programs submenu,
you would put your short cut in the respective directory)
To programically create a short cut you can use IShellLink
(See MSDN article).
Since you want to uninstall, that gets a lot more involved because you don't want to simply go deleting DLLs or other common files without checking dependencies.
I would recommend using a setup/installation generator, especially nowadays with Vista being so persnickety, it is getting rather complicated to roll your own installation
if you need anything more than a single executable and a start menu shortcut.
I have been using Paquet Builder setup generator for several years now.
(The registered version includes uninstall).
You've already got the main steps. One you left out is to install on the Start Menu and provide an option to create a desktop and/or quick launch icon.
I would encourage you to look into using a setup program, as suggested by Jeremy.