|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jun 2002
Città: NAPOLI!
Messaggi: 1310
|
[vb6] leggere chiavi del reg
mi serve che una mia applicazione "sappia" che os è installato.
credo che il controllo possa essere fatto leggendo la chiave del registro di configurazione dove c'è scritto che os uso. ora volevo sapere però come si fa ad assegnare ad una stringa il valore di una chiave del reg e se eventualmente c'è anche un altro modo per avere la stessa informazione. grazie |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Mar 2002
Città: Italy/Usa
Messaggi: 2817
|
con la premessa che non sono molto ferrato in vb6, la prima cosa che dovresti fare è di leggere il registro di sistema mettendo questo codice in una classe:
Codice:
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 RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal HKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal HKey As Long, ByVal dwIndex As Long, ByVal lpName As String, cbName As Long, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Private 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
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKey As Long) As Long
Public Enum HKeys
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_PERFORMANCE_DATA = &H80000004
HKEY_CURRENT_CONFIG = &H80000005
HKEY_DYN_DATA = &H80000006
End Enum
Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const KEY_CREATE_LINK = &H20
Private Const SYNCHRONIZE = &H100000
Private Const KEY_ALL_ACCESS = ( _
( _
STANDARD_RIGHTS_ALL Or _
KEY_QUERY_VALUE Or _
KEY_SET_VALUE Or _
KEY_CREATE_SUB_KEY Or _
KEY_ENUMERATE_SUB_KEYS Or _
KEY_NOTIFY Or _
KEY_CREATE_LINK _
) _
And _
( _
Not SYNCHRONIZE _
) _
)
Dim RootHKey As HKeys
Dim SubDir As String
Dim HKey As Long
Dim OpenRegOk As Boolean
__________________
"Utilizzando atomi pentavalenti drogheremo il silicio di tipo n; Utilizzando atomi trivalenti drogheremo il silicio di tipo p; Utilizzando della cannabis ci drogheremo noi e vedremo il silicio fare cose impossibili" - DSDT-HowTo |
|
|
|
|
|
#3 | |
|
Senior Member
Iscritto dal: Aug 2002
Città: Biella
Messaggi: 1882
|
Re: [vb6] leggere chiavi del reg
Quote:
é una mia funzione che utilizza le API, se nn ti piace cambiala pure ma cmq il modo di riperirle è cmq una parte della funzione. Codice:
Option Explicit
Public Enum OS_INFORMATION
OSI_PLATFORM
OSI_MAJOR_VERSION
OSI_MINOR_VERSION
OSI_BUILD_NUMBER
OSI_UPDATE
End Enum
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Public Function GetOSInformation(ByVal OSInformation As OS_INFORMATION) As String
Dim OSInfo As OSVERSIONINFO
'imposto la dimensione della struttura
OSInfo.dwOSVersionInfoSize = Len(OSInfo)
'prelevo le informazioni di windows
Call GetVersionEx(OSInfo)
Select Case OSInformation
Case 0
'testo di che genere di OS c'è
Select Case OSInfo.dwPlatformId
Case 0: GetOSInformation = "Windows 32s"
Case 1: GetOSInformation = IIf(OSInfo.dwMinorVersion = 0, "Windows 95", "Windows 98")
Case 2: GetOSInformation = IIf(OSInfo.dwMajorVersion = 4, "Windows NT", IIf(OSInfo.dwMinorVersion = 0, "Windows 2000", "Windows XP"))
End Select
Case 1: GetOSInformation = OSInfo.dwMajorVersion
Case 2: GetOSInformation = OSInfo.dwMinorVersion
Case 3: GetOSInformation = OSInfo.dwBuildNumber
Case 4: GetOSInformation = Left$(OSInfo.szCSDVersion, InStr(1, OSInfo.szCSDVersion, Chr$(0)))
End Select
End Function
Ti posto anche la funzione per sapere se un OS è base NT o no, magari ti serve... Codice:
Public Function IsWinNT() As Boolean Dim myOS As OSVERSIONINFO myOS.dwOSVersionInfoSize = Len(myOS) Call GetVersionEx(myOS) IsWinNT = (myOS.dwPlatformId = 2) '2 parametro piattaforma NT End Function
__________________
"Analizzando e valutando ogni giorno tutte le idee, ho capito che spesso tutti sono convinti che una cosa sia impossibile, finchè arriva uno sprovveduto che non lo sa e la realizza!" A. Einstein Ultima modifica di matpez : 09-01-2004 alle 14:04. |
|
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Mar 2002
Città: Italy/Usa
Messaggi: 2817
|
Aspettavo con ansia le tue correzioni
__________________
"Utilizzando atomi pentavalenti drogheremo il silicio di tipo n; Utilizzando atomi trivalenti drogheremo il silicio di tipo p; Utilizzando della cannabis ci drogheremo noi e vedremo il silicio fare cose impossibili" - DSDT-HowTo |
|
|
|
|
|
#5 | |
|
Senior Member
Iscritto dal: Aug 2002
Città: Biella
Messaggi: 1882
|
Quote:
__________________
"Analizzando e valutando ogni giorno tutte le idee, ho capito che spesso tutti sono convinti che una cosa sia impossibile, finchè arriva uno sprovveduto che non lo sa e la realizza!" A. Einstein |
|
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Jun 2002
Città: NAPOLI!
Messaggi: 1310
|
grazie
__________________
"catch a homo by his toe, man I don't know no more am I the only fuckin' one who's normal any more?" |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 23:08.



















