Пример позволяющий просмотреть установленные в системе программы.
#include <iostream.h> #include <conio.h> #include <windows.h>
int main() { LONG lResCode; DWORD dwValue = 256,dwIndex = 0; char szName[256]; HKEY hKey,hKeys; char szPathReg[MAX_PATH] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; LONG lRes=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",NULL,KEY_ALL_ACCESS,&hKey); if(lRes!=ERROR_SUCCESS){cout<<"Error RegOpenKeyEx"<<endl;} else { do { dwValue = 256;szName[0]='\0'; lResCode = RegEnumKey(hKey,dwIndex,szName,dwValue); if(lResCode == ERROR_SUCCESS) { cout<<"--------------------------------------------------\n"<<szName<<" = "; lstrcat(szPathReg,"\\"); lstrcat(szPathReg,szName); if(RegOpenKey(HKEY_LOCAL_MACHINE,szPathReg,&hKeys)==ERROR_SUCCESS) { if(RegQueryValueEx(hKeys,TEXT("DisplayName"),NULL,NULL,(LPBYTE)szPathReg,&dwValue)==ERROR_SUCCESS) { CharToOem(szPathReg,szPathReg); cout<<szPathReg<<endl; } else{cout<<"No DisplayName"<<endl;} } RegCloseKey(hKeys); szPathReg[0]='\0'; lstrcpy(szPathReg,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"); }else{cout<<"..."<<endl;} dwIndex++; }while(lResCode != ERROR_NO_MORE_ITEMS); } RegCloseKey(hKey); RegCloseKey(hKeys); cout<<"Press any key to continue"<<endl; while (!getch()); return 0; }
|