CPU FOR WINDOWS

econs Messages postés 4030 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 23 décembre 2008 - 14 juin 2005 à 07:55
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 - 27 juil. 2006 à 08:48
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/32023-cpu-for-windows

Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
27 juil. 2006 à 08:48
Dim NTXP, ME9x, a, b, c, d as string

ici, seul d est un String.... tous les autres sont des variant
et oui, VB ne fonctionne pas comme le C, sur ce point ^^

une constante Visu ? quelle constante ?
c'est le parametres de la fonction qui affiche ou masque certains controles

si je fais par exemple :

AfficheLibelles True

le Lbl4 sera masqué...
et ainsi de suite
Crash Ov Messages postés 11 Date d'inscription jeudi 20 octobre 2005 Statut Membre Dernière intervention 7 juillet 2009
26 juil. 2006 à 12:41
super! C exactement se que je chechais
Parconte pour le ;SP2; remplace les ; par rien

du genre sevicepack.caption = Replace(g,";","")
et comme dit RendfielD il faut typer tes variable dans ton cas il me semble que se son tous des string Dim NTXP, ME9x, a, b, c, d as string , Rendfield je vois pas l utilité de déclaré ta constante Visu ?
nicoboy89 Messages postés 17 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 15 juin 2005
15 juin 2005 à 14:46
Not visu ca ve dir non visible?Visu c une variable en faite?
J'ai fais ce que tu m'as dit mais quend je met option explicit en haut ca marche plus,

Private Sub Form_Load()

Dim NomCpu As String
Dim Sp As String
Dim ModCpu As String
Dim FreqCpu
Dim ID As String
Dim NomOrdi As String
Dim MarqueCpu As String

Set gui = CreateObject("WScript.Shell")
NomCpu = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\ProcessorNameString")
MarqueCpu = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\VendorIdentifier")
ModCpu = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\~MHz")
FreqCpu = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\Identifier")
ID = gui.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId")
NomOrdi = gui.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\Controlset001\Control\ComputerName\ComputerName\ComputerName")
Sp = gui.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\MinorVersion")

Lbl1.Caption = NomCpu
lbl2.Caption = ModCpu
lbl3.Caption = FreqCpu
Lbl5.Caption = ID
Lbl4.Caption = NomOrdi
lbl6.Caption = Mid(Sp, 2, Len(Sp) - 2) 'Merci a Psykos7
amd.Visible (MarqueCpu "AuthenticAMD") 'Merci à econs
intel.Visible Not (MarqueCpu "AuthenticAMD") 'pour cette partie.
Lbl4.Visible = True
lbl6.Visible = True
Lbl5.Visible = True
LblNomOrdi.Visible = True
LblSp.Visible = True
LblID.Visible = True
ordi.Visible = True
Lbl1.Visible = False
lbl3.Visible = False
lbl2.Visible = False
LblNomCpu.Visible = False
LblModCpu.Visible = False
LblmHz.Visible = False
LblFréqCpu.Visible = False
amd.Visible = False
intel.Visible = False

End Sub

Private Sub lblcmd1_Click()

Lbl4.Visible = True
lbl6.Visible = True
Lbl5.Visible = True
LblNomOrdi.Visible = True
LblSp.Visible = True
LblID.Visible = True
ordi.Visible = True
Lbl1.Visible = False
lbl3.Visible = False
lbl2.Visible = False
LblNomCpu.Visible = False
LblModCpu.Visible = False
LblmHz.Visible = False
LblFréqCpu.Visible = False
amd.Visible = False
intel.Visible = False

End Sub

Private Sub lblcmd2_Click()

Lbl4.Visible = False
lbl6.Visible = False
Lbl5.Visible = False
LblNomOrdi.Visible = False
LblSp.Visible = False
LblID.Visible = False
ordi.Visible = False
Lbl1.Visible = True
lbl3.Visible = True
lbl2.Visible = True
LblNomCpu.Visible = True
LblModCpu.Visible = True
LblmHz.Visible = True
LblFréqCpu.Visible = True
amd.Visible = True
intel.Visible = True

End Sub

Private Sub lblcmd3_Click()

Unload Me

End Sub
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
15 juin 2005 à 13:37
y'a du mieux...

pourquoi ne pas déclarer tes variables dans Form_Load
(là où elles sont utilisées...)

le Option Explicit indique que la déclaration des variables doit être obligatoirement présente. Ca evite des soucis aussi simples et dur a trouver que des fautes de frappe, par exemple.
nicoboy89 Messages postés 17 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 15 juin 2005
15 juin 2005 à 12:09
J'ai un peux retravaillé mon code:



Dim NomCpu As String
Dim Sp As String
Dim ModCpu As String
Dim FreqCpu
Dim ID As String
Dim NomOrdi As String
Dim g As String


Private Sub Form_Load()

Set gui = CreateObject("WScript.Shell")
NomCpu = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\ProcessorNameString")
Sp = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\VendorIdentifier")
ModCpu = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\~MHz")
FreqCpu = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\Identifier")
ID = gui.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId")
NomOrdi = gui.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\Controlset001\Control\ComputerName\ComputerName\ComputerName")
g = gui.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\MinorVersion")
Lbl1.Caption = NomCpu
lbl2.Caption = ModCpu
lbl3.Caption = FreqCpu
Lbl5.Caption = ID
Lbl4.Caption = NomOrdi
lbl6.Caption = Mid(g, 2, Len(g) - 2) 'Merci a Psykos7
amd.Visible (Sp "AuthenticAMD") 'Merci à econs
intel.Visible Not (Sp "AuthenticAMD") 'pour cette partie.
Lbl4.Visible = True
lbl6.Visible = True
Lbl5.Visible = True
LblNomOrdi.Visible = True
LblSp.Visible = True
LblID.Visible = True
ordi.Visible = True
Lbl1.Visible = False
lbl3.Visible = False
lbl2.Visible = False
LblNomCpu.Visible = False
LblModCpu.Visible = False
LblmHz.Visible = False
LblFréqCpu.Visible = False
amd.Visible = False
intel.Visible = False
End Sub

Private Sub lblcmd1_Click()
Lbl4.Visible = True
lbl6.Visible = True
Lbl5.Visible = True
LblNomOrdi.Visible = True
LblSp.Visible = True
LblID.Visible = True
ordi.Visible = True
Lbl1.Visible = False
lbl3.Visible = False
lbl2.Visible = False
LblNomCpu.Visible = False
LblModCpu.Visible = False
LblmHz.Visible = False
LblFréqCpu.Visible = False
amd.Visible = False
intel.Visible = False
End Sub

Private Sub lblcmd2_Click()
Lbl4.Visible = False
lbl6.Visible = False
Lbl5.Visible = False
LblNomOrdi.Visible = False
LblSp.Visible = False
LblID.Visible = False
ordi.Visible = False
Lbl1.Visible = True
lbl3.Visible = True
lbl2.Visible = True
LblNomCpu.Visible = True
LblModCpu.Visible = True
LblmHz.Visible = True
LblFréqCpu.Visible = True
amd.Visible = True
intel.Visible = True
End Sub

Private Sub lblcmd3_Click()
Unload Me
End Sub
nicoboy89 Messages postés 17 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 15 juin 2005
15 juin 2005 à 12:08
Option explicit sert à quoi?
Merci de ton aide ;-)
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
15 juin 2005 à 11:06
Je vois pas trop où commenter...

Voici une liste des actions entreprises...

j'ai renommé tes variables a,b,c... avec un nom plus parlant
je les ai definies en tant que String (toujours typer les variables)

Unload des feuilles plutot que End (a proscrire)

Une Procedure qui permet, en fonction d'un parametre va afficher ou masquer les labels

Enfin, le 'Option Explicit' , que tu peux activer
Outils -> Options -> General -> Declaration des variables obligatoire
nicoboy89 Messages postés 17 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 15 juin 2005
15 juin 2005 à 09:56
Ok merci pour ton code mais je suis débutant et la un peu paumé(:-|).
Peu-tu le commenter un peu SVP.
Merci
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
14 juin 2005 à 17:33
tu ne peut pas appeler tes procedures Lbl1 et lbl2 si tu as des controles qui portent ce nom là ....

tu peux simplement utiliser un parametre
autre chose, RENOMMES tes controles... Label1, c'est beau, mais pas très parlant.

voici une version un peu nettoyée...

Option Explicit

Private Sub AfficheLibelles(Visu as Boolean)
Lbl4.Visible = Not Visu
lbl6.Visible = Not Visu
Lbl5.Visible = Not Visu
ordi.Visible = Not Visu
Label6.Visible = Not Visu
Label7.Visible = Not Visu
Label5.Visible = Not Visu

Lbl1.Visible = Visu
lbl3.Visible = Visu
lbl2.Visible = Visu
amd.Visible = Visu
intel.Visible = Visu
Label1.Visible = Visu
Label2.Visible = Visu
Label3.Visible = Visu
Label4.Visible = Visu
End Sub


Private Sub Form_Load()
Dim gui as Object
Dim ProcessorNameString as String
Dim VendorIdentifier as String
Dim MHZ as String
Dim Identifier as String
Dim ProductId as String
Dim ComputerName as String
Dim MinorVersion as String

Set gui = CreateObject("WScript.Shell")
ProcessorNameString = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\ProcessorNameString")
VendorIdentifier = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\VendorIdentifier")
MHZ = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\~MHz")
Identifier = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\Identifier")
ProductId = gui.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId")
ComputerName = gui.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\Controlset001\Control\ComputerName\ComputerName\ComputerName")
MinorVersion = gui.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\MinorVersion")

Lbl1.Caption = ProcessorNameString
lbl2.Caption = MHZ
lbl3.Caption = Identifier
Lbl5.Caption = ProductId
Lbl4.Caption = ComputerName
lbl6.Caption = MinorVersion

AfficheLibelles False
If VendorIdentifier = "AuthenticAMD" Then
amd.Visible = True
Else
intel.Visible = True
End If
End Sub

Private Sub lblcmd1_Click()
AfficheLibelles False
End Sub

Private Sub lblcmd2_Click()
AfficheLibelles True
End Sub

Private Sub lblcmd3_Click()
Unload Me
End Sub
nicoboy89 Messages postés 17 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 15 juin 2005
14 juin 2005 à 17:13
Pourquoi ça ne marche pas (Le membre existe deja dans un module d'objet duquel le module est derivé)
Dim NTXP, ME9x, a, b, c, d, e, f
Dim g As String


Private Sub Form_Load()

Set gui = CreateObject("WScript.Shell")
a = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\ProcessorNameString")
b = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\VendorIdentifier")
c = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\~MHz")
d = gui.RegRead("HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0\Identifier")
e = gui.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId")
f = gui.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\Controlset001\Control\ComputerName\ComputerName\ComputerName")
g = gui.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\MinorVersion")
Lbl1.Caption = a
lbl2.Caption = c
lbl3.Caption = d
Lbl5.Caption = e
Lbl4.Caption = f
lbl6.Caption = Mid(g, 2, Len(g) - 2) 'Merci a Psykos7
amd.Visible (b "AuthenticAMD") 'Merci à econs
intel.Visible Not (b "AuthenticAMD") 'pour cette partie.
Lbl1
amd.Visible = False
intel.Visible = False
End Sub

Private Sub lblcmd1_Click()
Lbl1
End Sub

Private Sub lblcmd2_Click()
lbl2
End Sub

Private Sub lblcmd3_Click()
End
End Sub
Sub Lbl1()
Lbl4.Visible = True
lbl6.Visible = True
Lbl5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label5.Visible = True
ordi.Visible = True
Lbl1.Visible = False
lbl3.Visible = False
lbl2.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
amd.Visible = False
intel.Visible = False
End Sub
Sub lbl2()
Lbl4.Visible = False
lbl6.Visible = False
Lbl5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label5.Visible = False
ordi.Visible = False
Lbl1.Visible = True
lbl3.Visible = True
lbl2.Visible = True
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
amd.Visible = True
intel.Visible = True

End Sub
didyman Messages postés 86 Date d'inscription vendredi 26 novembre 2004 Statut Membre Dernière intervention 8 novembre 2007
14 juin 2005 à 15:48
tu te fait une nouvelle procédure

Private Sub lblcmd1_Click()
lbl1
end sub

sub lbl1()
Lbl4.Visible = True
lbl6.Visible = True
Lbl5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label5.Visible = True
ordi.Visible = True
Lbl1.Visible = False
lbl3.Visible = False
lbl2.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
amd.Visible = False
intel.Visible = False
end sub
nicoboy89 Messages postés 17 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 15 juin 2005
14 juin 2005 à 13:19
Merci psykos7
Comment est-ce que je peux utiliser des labels?
pour par exemple quand je click sur processeur ca aille a un label.
Je pensai à:

Private Sub lblcmd1_Click()
goto lbl1
end sub

lbl1:
Lbl4.Visible = True
lbl6.Visible = True
Lbl5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label5.Visible = True
ordi.Visible = True
Lbl1.Visible = False
lbl3.Visible = False
lbl2.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
amd.Visible = False
intel.Visible = False

Mais ca ne marche pas.
Un peu d'aide SVP.
Merci
Psykos7 Messages postés 60 Date d'inscription dimanche 15 octobre 2000 Statut Membre Dernière intervention 21 février 2008
14 juin 2005 à 12:21
euh .... fait un mid(tachaine, 2, len(tachaine)-2) plutot
Psykos7 Messages postés 60 Date d'inscription dimanche 15 octobre 2000 Statut Membre Dernière intervention 21 février 2008
14 juin 2005 à 12:19
pour enlever les 2 ";", fait un mid(tachaine, 2, len(tachaine)-3)
mr_vanquish_v12 Messages postés 3 Date d'inscription mercredi 10 décembre 2003 Statut Membre Dernière intervention 14 juin 2005
14 juin 2005 à 12:07
Ta source est vraiement sympa.Pour le sp2 je sais pas désolé.
nicoboy89 Messages postés 17 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 15 juin 2005
14 juin 2005 à 11:06
Est-ce que vous pourriez me dire comment copier le contenue d'une clée, y enlever 2 caratcères et l'afficher.
Exemple avc ";SP2;" comment enlever les 2 ;.
Merci de votre aide
nicoboy89 Messages postés 17 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 15 juin 2005
14 juin 2005 à 10:42
Dans mon code ce que tu propose ne marche pas.Merci quand meme.
:-)
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
14 juin 2005 à 09:29
Amélioration, je ne sais pas, Econs....

moins de lignes de code, mais le test de comparaison est répété ...

Ce qui s'approcherai le plus de ce que tu soumets serait :

amd.Visible (b "AuthenticAMD")
intel.Visible = Not amd.Visible
nicoboy89 Messages postés 17 Date d'inscription mardi 1 juin 2004 Statut Membre Dernière intervention 15 juin 2005
14 juin 2005 à 09:29
Merci, je comptes effectuer quelques MAJ de toute façon.
;-)
econs Messages postés 4030 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 23 décembre 2008 24
14 juin 2005 à 07:55
Petite amélioration :

---cette partie de code------
If b = "AuthenticAMD" Then
amd.Visible = True
intel.Visible = False
Else
amd.Visible = False
intel.Visible = True
End If
-----------peut se remplacer par --------
amd.Visible = (b= "AuthenticAMD")
intel.Visible = Not (b= "AuthenticAMD")


Sinon, bon exemple d'utilisation de WScript.Shell
Rejoignez-nous