Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Registry - mala pomoc

[es] :: Visual Basic 6 :: Registry - mala pomoc

[ Pregleda: 2357 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

celtic
Stevan Jovicevic
Zemun

Član broj: 26790
Poruke: 5
*.yubc.net



Profil

icon Registry - mala pomoc03.08.2004. u 14:07 - pre 202 meseci
Pretrazio sam forum i skinuo klasu koja je dovoljna da se po registry-u pise, cita i sve ostalo. E sad, posto sam relativni pocetnik, moze li neko samo da mi objasni kako se koriste metodi CreateKey, DeleteKey... Mislio sam da prvo treba zadati hkey pomocu blabla(ime klase).hkey = HKEY..., ali ni tada, sta god ja kucao u CreateKey, jednostavno nista ne stvori u registry-u.
Recimo
blabla.hkey = HKEY_LOCAL_MACHINE
blabla.CreateKey ("\Software\TrucTruc"), ne daje apsolutno nista. Posto nema errora, pretpostavljam da ja tu nesto ne kapiram kako treba. Pomoc!
 
Odgovor na temu

Ero S Ovoga Sveta

Član broj: 21509
Poruke: 173
*.teol.net



Profil

icon Re: Registry - mala pomoc04.08.2004. u 01:45 - pre 202 meseci
Evo probaj ovaj programcic iz uploada
Prikačeni fajlovi
 
Odgovor na temu

Ero S Ovoga Sveta

Član broj: 21509
Poruke: 173
*.teol.net



Profil

icon Re: Registry - mala pomoc04.08.2004. u 01:50 - pre 202 meseci
Predlazem Moderatorima da postave jedan TOP TOPIC o Registry-ju.
To nije obuhvaceno u TOP a ima dosta pitanja i problema.
 
Odgovor na temu

gio1000
Italia

Član broj: 1159
Poruke: 122
*.pool8252.interbusiness.it



Profil

icon Re: Registry - mala pomoc04.08.2004. u 02:14 - pre 202 meseci
Ovo kopiraj u Modul:

Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Type ACL
AclRevision As Byte
Sbz1 As Byte
AclSize As Integer
AceCount As Integer
Sbz2 As Integer
End Type

Type SECURITY_DESCRIPTOR
Revision As Byte
Sbz1 As Byte
Control As Long
Owner As Long
Group As Long
Sacl As ACL
Dacl As ACL
End Type

' HKEY Konstante
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_CONFIG = &H80000005 ' Win95
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_DYN_DATA = &H80000006 ' Win95
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_PERFORMANCE_DATA = &H80000004 ' WinNT
Public Const HKEY_USERS = &H80000003

' Osnovne funkcije
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Declare Function RegConnectRegistry Lib "advapi32.dll" Alias "RegConnectRegistryA" (ByVal lpMachineName As String, ByVal hKey As Long, phkResult As Long) As Long
Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
Declare Function RegFlushKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegGetKeySecurity Lib "advapi32.dll" (ByVal hKey As Long, ByVal SecurityInformation As Long, pSecurityDescriptor As SECURITY_DESCRIPTOR, lpcbSecurityDescriptor As Long) As Long
Declare Function RegSetKeySecurity Lib "advapi32.dll" (ByVal hKey As Long, ByVal SecurityInformation As Long, pSecurityDescriptor As SECURITY_DESCRIPTOR) As Long
Declare Function RegLoadKey Lib "advapi32.dll" Alias "RegLoadKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpFile As String) As Long
Declare Function RegUnLoadKey Lib "advapi32.dll" Alias "RegUnLoadKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Declare Function RegNotifyChangeKeyValue Lib "advapi32.dll" (ByVal hKey As Long, ByVal bWatchSubtree As Long, ByVal dwNotifyFilter As Long, ByVal hEvent As Long, ByVal fAsynchronus As Long) As Long
Declare Function RegQueryInfoKey Lib "advapi32.dll" Alias "RegQueryInfoKeyA" (ByVal hKey As Long, ByVal lpClass As String, lpcbClass As Long, lpReserved As Long, lpcSubKeys As Long, lpcbMaxSubKeyLen As Long, lpcbMaxClassLen As Long, lpcValues As Long, lpcbMaxValueNameLen As Long, lpcbMaxValueLen As Long, lpcbSecurityDescriptor As Long, lpftLastWriteTime As FILETIME) As Long
Declare Function RegReplaceKey Lib "advapi32.dll" Alias "RegReplaceKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpNewFile As String, ByVal lpOldFile As String) As Long
Declare Function RegRestoreKey Lib "advapi32.dll" Alias "RegRestoreKeyA" (ByVal hKey As Long, ByVal lpFile As String, ByVal dwFlags As Long) As Long
Declare Function RegSaveKey Lib "advapi32.dll" Alias "RegSaveKeyA" (ByVal hKey As Long, ByVal lpFile As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

' Prosirene funkcije(ne koriste se u Sub ili funkcijama)
Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
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
Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Long, lpcbData As Long) As Long
Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long

' Error Konstante
Public Const ERROR_SUCCESS = 0& ' operacija uspjela
Public Const ERROR_NONE = 0 ' Bez greske
Public Const ERROR_BADDB = 1 ' Korumpirana baza registra
Public Const ERROR_BADKEY = 2 ' Neispravan Key naziv
Public Const ERROR_CANTOPEN = 3 ' Nemoguce otvoriti key
Public Const ERROR_CANTREAD = 4 ' nemoguce ucitati key
Public Const ERROR_CANTWRITE = 5 ' nemoguce upisati key
Public Const ERROR_OUTOFMEMORY = 6 ' Out Of Memory
Public Const ERROR_ARENA_TRASHED = 7 ' Nepoznata greska
Public Const ERROR_ACCESS_DENIED = 8 ' Neodobren pristup registru
Public Const ERROR_INVALID_PARAMETERS = 87 ' Neispravan parametar
Public Const ERROR_NO_MORE_ITEMS = 259 ' Nema vise Item-a

' Registry Constants
Public Const REG_BINARY = 3
Public Const REG_CREATED_NEW_KEY = &H1 ' Novi key upisan
Public Const REG_DWORD = 4 ' 32-bit br.
Public Const REG_DWORD_BIG_ENDIAN = 5 ' 32-bit br.
Public Const REG_DWORD_LITTLE_ENDIAN = 4
Public Const REG_EXPAND_SZ = 2
Public Const REG_FULL_RESOURCE_DESCRIPTOR = 9
Public Const REG_LINK = 6
Public Const REG_MULTI_SZ = 7
Public Const REG_NONE = 0
Public Const REG_NOTIFY_CHANGE_ATTRIBUTES = &H2
Public Const REG_NOTIFY_CHANGE_LAST_SET = &H4
Public Const REG_NOTIFY_CHANGE_NAME = &H1
Public Const REG_OPENED_EXISTING_KEY = &H2
Public Const REG_NOTIFY_CHANGE_SECURITY = &H8
Public Const REG_OPTION_BACKUP_RESTORE = 4
Public Const REG_OPTION_CREATE_LINK = 2
Public Const REG_OPTION_NON_VOLATILE = 0
Public Const REG_OPTION_RESERVED = 0
Public Const REG_OPTION_VOLATILE = 1
Public Const REG_REFRESH_HIVE = &H2
Public Const REG_RESOURCE_LIST = 8
Public Const REG_RESOURCE_REQUIREMENTS_LIST = 10
Public Const REG_SZ = 1
Public Const REG_WHOLE_HIVE_VOLATILE = &H1
Public Const REG_LEGAL_CHANGE_FILTER = (REG_NOTIFY_CHANGE_NAME Or REG_NOTIFY_CHANGE_ATTRIBUTES Or REG_NOTIFY_CHANGE_LAST_SET Or REG_NOTIFY_CHANGE_SECURITY)
Public Const REG_LEGAL_OPTION = (REG_OPTION_RESERVED Or REG_OPTION_NON_VOLATILE Or REG_OPTION_VOLATILE Or REG_OPTION_CREATE_LINK Or REG_OPTION_BACKUP_RESTORE)

' Ostale konstante
Public Const READ_CONTROL = &H20000
Public Const SYNCHRONIZE = &H100000
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const STANDARD_RIGHTS_READ = READ_CONTROL
Public Const STANDARD_RIGHTS_WRITE = READ_CONTROL


Public Sub CreateKey(ByVal hKey As Long, ByVal Key As String, Optional SubKey As Variant)

If Not IsMissing(SubKey) Then
Temp& = RegCreateKey(hKey, Key & "\" & SubKey, hHnd&)
Else
Temp& = RegCreateKey(hKey, Key, hHnd&)
End If

Call RegError(Temp&)

Temp& = RegCloseKey(hHnd&)

Call RegError(Temp&)

End Sub



Private Sub RegError(ByVal ReturnedData As Long)

Select Case ReturnedData

Case ERROR_BADDB
RegErr$ = "Korumpirana baza registra!"
Case ERROR_BADKEY
RegErr$ = "Naziv kljuca neprihvatljiv"
Case ERROR_CANTOPEN
RegErr$ = "Nemoguce otvoriti kljuc"
Case ERROR_CANTREAD
RegErr$ = "nemoguce ucitati kljuc"
Case ERROR_CANTWRITE
RegErr$ = "Nemoguce upisati kljuc"
Case ERROR_OUTOFMEMORY
RegErr$ = "Out Of Memory"
Case ERROR_ACCESS_DENIED
RegErr$ = "Nemoguc pristup registru"
Case ERROR_INVALID_PARAMETERS
RegErr$ = "Nekorektan parametar"
Case ERROR_NO_MORE_ITEMS
RegErr$ = "Nema vise Item-a"

End Select

If RegErr$ <> "" Then MsgBox "Greska registra: " & RegErr$, vbCritical, "Error"

End Sub

Public Sub SaveString(ByVal hKey As Long, ByVal Key As String, ByVal SubKey As String, ByVal ValueTitle As String, ByVal ValueData As String)

KeyPath$ = Key + "\" + SubKey

Temp& = RegCreateKey(hKey, KeyPath$, hHnd&)

Call RegError(Temp&)

Temp& = RegSetValueEx(hHnd&, ValueTitle, 0, REG_SZ, ByVal ValueData, Len(ValueData))

Call RegError(Temp&)

Temp& = RegCloseKey(hHnd&)

Call RegError(Temp&)

End Sub

Ovo u Form:
Private Sub Command1_Click()
'Ovim pozivas stvaranje novog kljuca
Call CreateKey(HKEY_CURRENT_CONFIG, "NoviKljuc")
End Sub
'Ovim upisujes neki podatak
Private Sub Command2_Click()
Call SaveString(HKEY_CURRENT_CONFIG, "NoviKljuc", "", "Proba", "uspjelo")
End Sub
 
Odgovor na temu

celtic
Stevan Jovicevic
Zemun

Član broj: 26790
Poruke: 5
*.yubc.net



Profil

icon Re: Registry - mala pomoc04.08.2004. u 15:07 - pre 201 meseci
Za Eru: Hvala, tvoj program radi posao.

Za Gio1000: Uradio sam kao sto si napisao, ali izbacuje: hHnd& - variable not defined (ili tako nesto). Koliko se ja secam, to mu dodje neka implicitna deklaracija, ali nisam siguran i ne znam kako to da sredim.
 
Odgovor na temu

[es] :: Visual Basic 6 :: Registry - mala pomoc

[ Pregleda: 2357 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.