Odczytać z rejestru listę zainstalowanych programów

0

Nie wiem od czego zacząć i na necie nie ma zbyt dużo przydatnych informacji.

Wszystkie zainstalowane programy mieszczą się w... "Software\Microsoft\CurrentVersion\Uninstall"
Ale jak wejść do każdego z folderów i wczytać wartość znajdującą się pod "DisplayName" w pętli?

0

będde musiał tutaj wykorzystać Enumerate by można było odczytać każdą kolejną nazwę programu ?

Może mała wskazówka bo naprawdę nie wiem jak przeczytać kazdego klucza wartość string o nazwie DisplayName

0
#include <windows.h>
#include <stdbool.h>
#include <stdio.h>
#pragma comment(lib,"advapi32.lib")

int main(){
	HKEY hKey;
	DWORD cSubKeys;		//Used to store the number of Subkeys
	DWORD maxSubkeyLen;	//Longest Subkey name length
	DWORD retCode;		//Return values of calls
	//RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion",0,KEY_ALL_ACCESS,&hKey);
	RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",0,KEY_ALL_ACCESS,&hKey);
    int i=0;

	RegQueryInfoKey(hKey,	// key handle
	NULL,			// buffer for class name
	NULL,			// size of class string
	NULL,			// reserved
	&cSubKeys,		// number of subkeys
	&maxSubkeyLen,		// longest subkey length
	NULL,			// longest class string 
	NULL,			// number of values for this key 
	NULL,			// longest value name 
	NULL,			// longest value data 
	NULL,			// security descriptor 
	NULL);			// last write time
	
	if(cSubKeys>0){
		char currentSubkey[MAX_PATH];

		for(;i < cSubKeys;i++){
			DWORD currentSubLen=MAX_PATH;

			retCode=RegEnumKeyEx(hKey,	// Handle to an open/predefined key
			i,				// Index of the subkey to retrieve.
			currentSubkey,			// buffer to receives the name of the subkey
			&currentSubLen,			// size of that buffer
			NULL,				// Reserved
			NULL,				// buffer for class string 
			NULL,				// size of that buffer
			NULL);				// last write time

			if(retCode==ERROR_SUCCESS){
				printf("(%d) %s\n", i+1, currentSubkey);
			}
		}
	}

	RegCloseKey(hKey); 
	getchar();
	return 0;

}
 

Dzięki za pomoc btw trochę pomogło zrozumieć o co chodzi No jutro resztę spróbuje wypleść.

0

RegQueryValueEx pobiera adres z twojego hKey i buf, oraz rozmiar bufora wyjściowego lpcbData. Zapisuje typ danej do lpType, samą daną do bufora lpData, a jej faktyczny rozmiar z powrotem do lpcbData. Jeśli się udało, zwraca ERROR_SUCCESS.

1 użytkowników online, w tym zalogowanych: 0, gości: 1