|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Member
Iscritto dal: Feb 2003
Messaggi: 74
|
[C++] Aggiungere chiave nel Registro di Windows
Salve. Uso Visual C++.
Vorrei sapere come fare ad aggiungere e cancellare una chiave col rispettivo valore nel registro di windows xp. Ho provato a vedere qualche esempio sul "RegCreateKey" e sul "RegSetValueEx" ma sono esempi troppo complessi per me. Dove posso trovare una spiegazione (possibilmente in italiano) o trovare un esempio più semplice? Grazie ![]() Max! |
![]() |
![]() |
![]() |
#2 | |
Senior Member
Iscritto dal: Nov 2005
Città: TO
Messaggi: 5206
|
Quote:
Per creare una chiave, esempio: Codice:
LONG lResult; HKEY hKey; lResult = RegCreateKeyEx (HKEY_CURRENT_USER, "bla\\bla\\bla...", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); if (lResult == ERROR_SUCCESS) { .... RegCloseKey (hKey); }
__________________
Andrea, SCJP 5 (91%) - SCWCD 5 (94%) |
|
![]() |
![]() |
![]() |
#3 |
Member
Iscritto dal: Feb 2003
Messaggi: 74
|
Ciao.
Allora...ho scritto il codice che posto qui sotto: LONG lResult; HKEY hKey; lResult = RegCreateKeyEx (HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); If (lResult == ERROR_SUCCESS) { cout << "OK! Registro modificato!"; RegCloseKey (hKey); } e mi esce l'errore "Errore: C2664: 'RegCreateKeyExW': impossibile convertire il parametro 2 da 'const char [46]' a 'LPCWSTR' ". Cosa significa? P.S. : dove posso trovare la documentazione delle API Win32 ? Ciao Max! |
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Mar 2006
Città: Bergamo
Messaggi: 2499
|
wsprintf(szBuf, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s", pszLogName, pszSrcName);
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, szBuf, 0, NULL, REG_OPTION_NON_VOLATILE,KEY_WRITE, NULL, &hk, &dwDisp)) { printf("Could not create the registry key."); return FALSE; } questo è un esempio dal sito msdn |
![]() |
![]() |
![]() |
#5 | |
Senior Member
Iscritto dal: Oct 2005
Messaggi: 3306
|
Quote:
Per la documentazione cerca su www.msdn.com |
|
![]() |
![]() |
![]() |
#6 | |
Senior Member
Iscritto dal: Nov 2005
Città: TO
Messaggi: 5206
|
Quote:
Inoltre la chiave 'Run' che hai indicato è molto probabile (al 99%) che sia già esistente, quindi RegCreateKeyEx fa nient'altro che aprire la chiave e ritornare l'handle.
__________________
Andrea, SCJP 5 (91%) - SCWCD 5 (94%) |
|
![]() |
![]() |
![]() |
#7 | |
Member
Iscritto dal: Feb 2003
Messaggi: 74
|
Quote:
![]() Grazie a tutti dell'aiuto! Max! |
|
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 12:37.