vbsecure

i want the list of programs that are installed on my pc in my code

how can i get




Re: Visual C++ General retrives installed programs

Simple Samples

Since your code installs the programs, it can keep a list.






Re: Visual C++ General retrives installed programs

pawanpc

actually i wanted to get a list of all installed software on my system






Re: Visual C++ General retrives installed programs

Aleksandr Tokarev

Code Snippet

#import "progid: WindowsInstaller.Installer"

LPCWSTR MsiVersion(LPCWSTR version)

{

static WCHAR strver[256];

int ver = _ttoi(version);

swprintf_s(strver, L"%d.%d.%d", ver/65536/256 , (ver/65535) % 256, ver % 65536);

return strver;

}

int _tmain(int argc, _TCHAR* argv[])

{

CoInitialize(NULL);

{

WindowsInstaller::InstallerPtr Installer(__uuidof(WindowsInstaller::Installer));

WindowsInstaller::StringListPtr codes = Installer->Products;

for(int i = 0; i < codes->Count; i++)

{

wcout<<codes->Item[i]

<<L" - "

<<Installer->ProductInfo[codes->Item[i], L"ProductName"]

<<L" ("

<<MsiVersion(Installer->ProductInfo[codes->Item[i], L"Version"])

<<L")"

<<endl;

}

}

CoUninitialize();





Re: Visual C++ General retrives installed programs

Aleksandr Tokarev

Code Snippet

#include "Msi.h"

#pragma comment(lib, "Msi.lib")

int _tmain(int argc, _TCHAR* argv[])

{

TCHAR pcode[39];

DWORD sz = 0, newsz = 0;

UINT ret = ERROR_SUCCESS;

int i = 0;

LPTSTR name = NULL;

while(ERROR_SUCCESS == (ret = MsiEnumProducts(i, pcode)))

{

if(ERROR_SUCCESS == MsiGetProductInfo(

pcode,

INSTALLPROPERTY_INSTALLEDPRODUCTNAME,

NULL,

&newsz))

{

if(newsz > sz)

{

delete [] name;

name = new TCHAR[newsz + 1];

sz = newsz;

}

newsz = sz + 1;

if(ERROR_SUCCESS == MsiGetProductInfo(

pcode,

INSTALLPROPERTY_INSTALLEDPRODUCTNAME,

name,

&newsz))

{

wcout<<name<<endl;

}

else

cout<<"Error while getting product name"<<endl;

}

else

cout<<"Error while getting product name"<<endl;

i++;

}

delete [] name;

if(ret != ERROR_NO_MORE_ITEMS)

cout<<"Error: "<<ret<<endl;

}





Re: Visual C++ General retrives installed programs

Simple Samples

Do you mean software your program installed or software not installed by your program Certainly not all software was instlled by your program but your original question was not clear and I am not sure it is clarified but I hope I understand. I will assume "all installed software" means all software, regardless of how it was installed.

It is nearly impossible to detect all software. You could scan all drives looking for exe files but obviously there would be many exceptions. Probably what you are asking is how to detect installations of software. Even that is not reliable; it is dependent on the installation software. Software installed by the Windows Installer can be queried using the Windows Installer; see Windows Installer.






Re: Visual C++ General retrives installed programs

Simple Samples

This question was also asked in list of installed software.