Lire clé

Résolu
jrbleboss Messages postés 480 Date d'inscription jeudi 6 mai 2004 Statut Membre Dernière intervention 3 septembre 2007 - 25 mars 2005 à 20:26
jrbleboss Messages postés 480 Date d'inscription jeudi 6 mai 2004 Statut Membre Dernière intervention 3 septembre 2007 - 25 mars 2005 à 23:14
Bonjour,



Tou d'abord ne me dites pas d'aller voir les sorces car je les aient toutes vu ey ca marche toujours pas.



pourquoi ce code ne marche pas tout est déclaré etc...



Call RegOpenKey(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\SYSTEM\Central\Processor\0", RegCle)

Call RegQueryValueEx(RegCle, "ProcessorNameString", 0, 1, RegValeur, Len(RegValeur))

Call RegCloseKey(RegClé)

JRB

4 réponses

cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 21
25 mars 2005 à 22:03
Heu, je t'ai répondu sur un précédent post où tu posais la question avec wsh.

Alors, version avec API :

DANS UN MODULE
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const REG_SZ As Long = 1
Public Const ERROR_SUCCESS = 0&


Declare Function RegOpenKey _
Lib "advapi32" Alias "RegOpenKeyA" _
( _
ByVal hKey As Long, _
ByVal lpSubKey As String, _
phkResult As Long _
) As Long


Declare Function RegQueryValueEx _
Lib "advapi32" 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


Public Function GetString(hKey As Long, strPath As String, strValue As String) As String
Dim Keyhand As Long, lValueType As Long
Dim strBuf As String, lDataBufSize As Long


Call RegOpenKey(hKey, strPath, Keyhand)
Call RegQueryValueEx(Keyhand, strValue, 0&, lValueType, ByVal 0&, lDataBufSize)
If lValueType = REG_SZ Then
strBuf = String(lDataBufSize, " ")
If RegQueryValueEx(Keyhand, strValue, 0&, 0&, ByVal strBuf, lDataBufSize) = ERROR_SUCCESS Then
GetString = Split(strBuf, Chr$(0))(0)
End If
End If

End Function


UTILISATION
MsgBox GetString(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\SYSTEM\CentralProcessor\0", "Identifier")

Essaie cette méthode et celle que je t'ai donnée dans ton autre post et compare. Les 2 fonctionnent, à toi de choisir.

Loup Gris
3
cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
25 mars 2005 à 21:45
Lol, tu peux expliquer le "ca ne marche pas" ??? C'est le genre d'expressions qui veulent à la fois tout dire et rien dire !

DarK Sidious

Un API Viewer (pour le VB, VB.NET, C, C# et Delphi) : www.ProgOtoP.com/popapi/
0
cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 21
25 mars 2005 à 22:06
Et n'oublie pas que ce n'est pas Central\Processor mais CentralProcessor

Loup Gris
0
jrbleboss Messages postés 480 Date d'inscription jeudi 6 mai 2004 Statut Membre Dernière intervention 3 septembre 2007 1
25 mars 2005 à 23:14
Oui merci Canis Lupus c'est bon grace a toi ca marche

Encore merci.

JRB
0
Rejoignez-nous