Sub test2() 'source:[URL="http://www.blogger.com/profile/16715160344457148874"]Blogger: Profil d'utilisateur : Richard Binning[/URL]
On Error Resume Next
Dim WshShell
Dim OsType
Set WshShell = CreateObject("WScript.Shell")
OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
If OsType = "x86" Then
MsgBox "Windows 64bit system detected"
ElseIf OsType = "AMD64" Then
MsgBox "ERROR !"
End If
End Sub
Bonjour,J'ai du mal à suivre... Et je remarque que certains aussi...
Ce qui me permettrait d'adapter le code de masquage de la bande bleue des USF suivant cette donnée.
Sub a() 'renvoie 32 sur un PC sous XP HOME SP3)
Dim OSVER
Set OSVER = GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'")
MsgBox OSVER.addresswidth & "-bit"
End Sub
Sub test()
MsgBox Application.OperatingSystem
End Sub
Merci à ceux et celles qui le veulent bien de tester cette macro de votre côté et de me retourner son résultat en me précisant également :Windows (64-bit) NT 6.01
Sub a() 'renvoie 32 sur un PC sous XP HOME SP3)
Dim OSVER
Set OSVER = GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'")
MsgBox OSVER.addresswidth & "-bit"
End Sub
A+1) pour le système d'exploitation :
- Windows 7 Edition Familiale Premium
- système d'exploitation 64 bits
2) pour la version d'Office : Microsoft Office 2010 64 bits
Sub test3()
On Error Resume Next
Dim WshShell
Dim OsType
Set WshShell = CreateObject("WScript.Shell")
OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\" & _
"Session Manager\Environment\PROCESSOR_ARCHITECTURE")
If OsType = "x86" Then
MsgBox "Your System is Windows 32bit", , "Win7 Home Premium"
ElseIf OsType <> "x86" Then
MsgBox "GO SEE YOUR DEALER !!", , "Win7 Home Premium"
End If
Sub test()
MsgBox Application.OperatingSystem
End Sub
'ai tenté d'écrire l'adaptation du code suivant ce que m'a proposé David 84.
Mais j'ai été obligé de mettre des ' car les lignes étaient systématiquement mises en rouge!
Donc; je ne peux pas écrire un choix la suivant version constatée!!!
Comme nous l’avons vu plus haut, il existe deux constantes de compilation conditionnelle : VBA7 et Win64. Pour garantir la compatibilité descendante avec les versions précédentes d’Office, on utilise la constante VBA7 (il s’agit du cas le plus courant) afin d’empêcher le code 64 bits de s’exécuter dans la version antérieure d’Office. Pour le code qui diffère entre la version 32 bits et la version 64 bits, tel que l’appel d’une API mathématique qui utilise LongLong pour sa version 64 bits et Long pour sa version 32 bits, on utilise la constante Win64. Le code suivant illustre l’utilisation de ces deux constantes.
VBA
#if Win64 then
Declare PtrSafe Function MyMathFunc Lib "User32" (ByVal N As LongLong) As LongLong
#else
Declare Function MyMathFunc Lib "User32" (ByVal N As Long) As Long
#end if
#if VBA7 then
Declare PtrSafe Sub MessageBeep Lib "User32" (ByVal N AS Long)
#else
Declare Sub MessageBeep Lib "User32" (ByVal N AS Long)
#end if
Pour résumer, si vous écrivez du code 64 bits et que prévoyez de l’utiliser dans des versions précédentes de Microsoft Office, il faut utiliser la constante de compilation conditionnelle VBA7. En revanche, si vous écrivez du code 32 bits dans Office 2010, ce code fonctionne tel que dans les versions précédentes d’Microsoft Office sans la constante de compilation. Si vous souhaitez être sûr d’utiliser des instructions 32 bits pour les versions 32 bits et des instructions 64 bits pour les versions 64 bits, la meilleure solution consiste à utiliser la constante de compilation conditionnelle Win64.
#If VBA7 Then
Declare PtrSafe Function GetWindowLongA Lib "User32" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare PtrSafe Function SetWindowLongA Lib "User32" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare PtrSafe Function FindWindowA Lib "User32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare PtrSafe Function DrawMenuBar Lib "User32" (ByVal hWnd As Long) As Long
#Else
Declare Function GetWindowLongA Lib "user32" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLongA Lib "user32" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
#End If
Windows (32-bits) NT 5.01
Windows (32-bits) NT 6.01
Sub test()
MsgBox Application.OperatingSystem
End Sub
Sub a() 'renvoie 32 sur un PC sous XP HOME SP3)
Dim OSVER
Set OSVER = GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'")
MsgBox OSVER.addresswidth & "-bit"
End Sub
Sub WMI_nous_en_dit_toujours_plus()
Dim objWMIService, objOS, colOSes
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS In colOSes
Debug.Print "Computer Name: " & objOS.CSName
Debug.Print "Operating System"
Debug.Print " Caption: " & objOS.Caption 'Name
Debug.Print " Version: " & objOS.Version 'Version & build
Debug.Print " BuildNumber: " & objOS.BuildNumber 'Build
Debug.Print " BuildType: " & objOS.BuildType
Debug.Print " OSProductSuite: " & objOS.OSProductsuite 'OS Product suite
'Debug.Print " OSArchitecture: " & objOS.OSArchitecture
'Debug.Print " WOWEnvironment: " & objOS.WOWEnvironment
Debug.Print " OSType: " & objOS.OSType
Debug.Print " OtherTypeDescription: (2003 Server R2 release only)" & objOS.OtherTypeDescription
Debug.Print " ServicePackMajorVersion: " & objOS.ServicePackMajorVersion & "." & _
objOS.ServicePackMinorVersion
Next
Debug.Print "Processors"
Dim colCompSys, objCS
Set colCompSys = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objCS In colCompSys
Debug.Print " NumberOfProcessors: " & objCS.NumberOfProcessors
Debug.Print " NumberOfLogicalProcessors: " & objCS.NumberOfLogicalProcessors
'Debug.Print " PCSystemType: " & objCS.PCSystemType
Next
Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objProcessor In colProcessors
Debug.Print " Manufacturer: " & objProcessor.Manufacturer
Debug.Print " Name: " & objProcessor.Name
Debug.Print " Description: " & objProcessor.Description
Debug.Print " ProcessorID: " & objProcessor.ProcessorID
Debug.Print " Architecture: " & objProcessor.Architecture
Debug.Print " AddressWidth: " & objProcessor.AddressWidth
Debug.Print " NumberOfCores: " & objProcessor.NumberOfCores
Debug.Print " DataWidth: " & objProcessor.DataWidth
Debug.Print " Family: " & objProcessor.Family
Debug.Print " MaximumClockSpeed: " & objProcessor.MaxClockSpeed
Next
End Sub
Sub WMI_nous_en_dit_toujours_plus()
Dim objWMIService, objOS, colOSes
1 Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
2 Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
3 For Each objOS In colOSes
4 Debug.Print "Computer Name: " & objOS.CSName
5 Debug.Print "Operating System"
6 Debug.Print " Caption: " & objOS.Caption 'Name
7 Debug.Print " Version: " & objOS.Version 'Version & build
8 Debug.Print " BuildNumber: " & objOS.BuildNumber 'Build
9 Debug.Print " BuildType: " & objOS.BuildType
10 Debug.Print " OSProductSuite: " & objOS.OSProductsuite 'OS Product suite
11 Debug.Print " OSArchitecture: " & objOS.OSArchitecture
'Debug.Print " WOWEnvironment: " & objOS.WOWEnvironment
12 Debug.Print " OSType: " & objOS.OSType
13 Debug.Print " OtherTypeDescription: (2003 Server R2 release only)" & objOS.OtherTypeDescription
14 Debug.Print " ServicePackMajorVersion: " & objOS.ServicePackMajorVersion & "." & _
objOS.ServicePackMinorVersion
15 Next
16 Debug.Print "Processors"
Dim colCompSys, objCS
17 Set colCompSys = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
18 For Each objCS In colCompSys
19 Debug.Print " NumberOfProcessors: " & objCS.NumberOfProcessors
20 Debug.Print " NumberOfLogicalProcessors: " & objCS.NumberOfLogicalProcessors
21 Debug.Print " PCSystemType: " & objCS.PCSystemType
22 Next
23 Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor")
24 For Each objProcessor In colProcessors
25 Debug.Print " Manufacturer: " & objProcessor.Manufacturer
26 Debug.Print " Name: " & objProcessor.Name
27 Debug.Print " Description: " & objProcessor.Description
28 Debug.Print " ProcessorID: " & objProcessor.ProcessorID
29 Debug.Print " Architecture: " & objProcessor.Architecture
30 Debug.Print " AddressWidth: " & objProcessor.AddressWidth
31 Debug.Print " NumberOfCores: " & objProcessor.NumberOfCores
32 Debug.Print " DataWidth: " & objProcessor.DataWidth
33 Debug.Print " Family: " & objProcessor.Family
34 Debug.Print " MaximumClockSpeed: " & objProcessor.MaxClockSpeed
35 Next
End Sub
Computer Name: PORTABLE
Operating System
Caption: Microsoft Windows 7 Édition Familiale Premium
Version: 6.1.7601
BuildNumber: 7601
BuildType: Multiprocessor Free
OSProductSuite: 768
OSArchitecture: 64 bits
OSType: 18
OtherTypeDescription: (2003 Server R2 release only)
ServicePackMajorVersion: 1.0
Processors
NumberOfProcessors: 1
NumberOfLogicalProcessors: 2
PCSystemType: 2
Manufacturer: GenuineIntel
Name: Pentium(R) Dual-Core CPU T4500 @ 2.30GHz
Description: Intel64 Family 6 Model 23 Stepping 10
ProcessorID: BFEBFBFF0001067A
Architecture: 9
AddressWidth: 64
NumberOfCores: 2
DataWidth: 64
Family: 191
MaximumClockSpeed: 2300
A+Computer Name: DAVID-PC
Operating System
Caption: Microsoft Windows*7 Édition Familiale Premium
Version: 6.1.7601
BuildNumber: 7601
BuildType: Multiprocessor Free
OSProductSuite: 768
OSType: 18
OtherTypeDescription: (2003 Server R2 release only)
ServicePackMajorVersion: 1.0
Processors
NumberOfProcessors: 1
NumberOfLogicalProcessors: 4
Manufacturer: GenuineIntel
Name: Intel(R) Core(TM) i5-2400S CPU @ 2.50GHz
Description: Intel64 Family 6 Model 42 Stepping 7
ProcessorID: BFEBFBFF000206A7
Architecture: 9
AddressWidth: 64
NumberOfCores: 4
DataWidth: 64
Family: 191
MaximumClockSpeed: 2501