Metti in un modulo a parte questo codice:
e quindi richiama la funzione in questo modo:codice:Public Const HKEY_CLASSES_ROOT = &H80000000 Public Const HKEY_CURRENT_CONFIG = &H80000005 Public Const HKEY_CURRENT_USER = &H80000001 Public Const HKEY_DYN_DATA = &H80000006 Public Const HKEY_LOCAL_MACHINE = &H80000002 Public Const HKEY_PERFORMANCE_DATA = &H80000004 Public Const HKEY_USERS = &H80000003 Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _ (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _ ByVal samDesired As Long, phkResult As Long) As Long Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As _ Long Private Const KEY_READ = &H20019 ' ((READ_CONTROL Or KEY_QUERY_VALUE Or ' KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not ' SYNCHRONIZE)) 'Return True if a Registry key exists Public Function CheckRegistryKey(ByVal hKey As Long, ByVal KeyName As String) As _ Boolean Dim handle As Long ' Try to open the key If RegOpenKeyEx(hKey, KeyName, 0, KEY_READ, handle) = 0 Then ' The key exists CheckRegistryKey = True ' Close it before exiting RegCloseKey handle End If End Function
codice:If CheckRegistryKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CCleaner") Then Label1.Caption = "La chiave esiste." Els Label1.Caption = "La chiave non esiste." End If

Rispondi quotando