Je cherche à programmer dans Access 2007 l'affichage de la version de Windows et du 32/64 bits. Dans la rubrique '' Savoir quelle version de windows (XP, Seven 32b, Seven 64b) '' du site (https://www.developpez.net/forums/d1...32b-seven-64b/), la procédure est décrite jusqu'à Windows Seven, auquel j'y est ajouté les versions Windows 8 et Server 2012 (code 6.2).
Selon Microsoft, Windows 8.1 et Server 2012 R2 correspond au code 6.3, et Windows 10 et Server 2016 au code 10.0. Après ajout des lignes pour ces codes, la procédure affiche toujours le code 6.2 (soit Windows 8).
Toujours selon Microsoft (https://msdn.microsoft.com/fr-fr/lib...(v=vs.85).aspx), des lignes de programmation pour différencier Windows 8 et 10 seraient à créer. Et là, je n'y arrive pas. Quelqu'un pourrait-il m'aider ?
Voilà mon code actuel :
Déclaration
Fonction
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 Option Compare Database Option Explicit 'API Windows pour version de Windows Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFOEX) As Integer 'API Windows pour chercher si le système est en 64 bytes Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProc As Long, bWow64Process As Boolean) As Long Private Const VER_NT_WORKSTATION = 1 ' Le système d'exploitation est Windows 7, Windows Vista, Windows XP Professional, Windows XP Home Edition, or Windows 2000 Professional. Private Const VER_PLATFORM_WIN32_WINDOWS = 1 Private Type OSVERSIONINFOEX dwOSVersionInfoSize As Long ' La taille de cette structure de données, en octets dwMajorVersion As Long ' Le nombre de la version majeure du système d'exploitation dwMinorVersion As Long ' Le nombre de la version mineure du système d'exploitation dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 wServicePackMajor As Integer wServicePackMinor As Integer wSuiteMask As Integer wProductType As Byte ' Autre information supplémentaires sur le système et notamment pour VER_NT_WORKSTATION, wProductType = 1 wReserved As Byte End Type
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 Public Function VersionWindows(ByRef Sp As String) As String ' Fonction pour identifier les versions de Windows [Windows XP, Seven 32 et 64 bytes] Dim Os As OSVERSIONINFOEX Dim Handle As Long Dim Est64bit As Boolean Dim Bytes As String Sp = "" 'Initialise la valeur à false : il n'y a pas Wow64 process Est64bit = False VersionWindows = "Système non prévu" 'On vérifie que la dll kernel32.dll contient bien une méthode IsWow64Process Handle = GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process") 'Si la fonction IsWow64Process existe on l'utise pour déterminer si on est en 64 bytes If Handle > 0 Then IsWow64Process GetCurrentProcess(), Est64bit If Est64bit = False Then Bytes = "32 bit" Else Bytes = "64 bit" End If Os.dwOSVersionInfoSize = Len(Os) GetVersionExA Os 'On teste sur les versions de Windows If Os.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then Select Case Os.dwMinorVersion Case 0 VersionWindows = "95" Case 10 VersionWindows = "98" Case 90 VersionWindows = "Me" End Select Exit Function End If Select Case CStr(Os.dwMajorVersion & "." & Os.dwMinorVersion) Case "3.0" VersionWindows = "NT 3.51" Case "4.0" VersionWindows = "NT 4.0" Case "5.0" VersionWindows = "Windows 2000" Case "5.1" VersionWindows = "Windows XP" Case "5.2" If Os.wProductType = VER_NT_WORKSTATION Then VersionWindows = "Windows XP Pro 64 bit" Else VersionWindows = "Server 2003, Home ou R2" End If Case "6.0" If Os.wProductType = VER_NT_WORKSTATION Then VersionWindows = "VISTA" & "-" & Bytes Else VersionWindows = "Server 2008" & "-" & Bytes End If Case "6.1" If Os.wProductType = VER_NT_WORKSTATION Then VersionWindows = "SEVEN" & "-" & Bytes Else VersionWindows = "Server 2008 R2" & "-" & Bytes End If Case "6.2" If Os.wProductType = VER_NT_WORKSTATION Then VersionWindows = "Windows 8" & "-" & Bytes Else VersionWindows = "Server 2012" & "-" & Bytes End If Case "6.3" If Os.wProductType = VER_NT_WORKSTATION Then VersionWindows = "Windows 8.1" & "-" & Bytes Else VersionWindows = "Windows Server*2012*R2" & "-" & Bytes End If Case "10.0" If Os.wProductType = VER_NT_WORKSTATION Then VersionWindows = "Windows*10" & "-" & Bytes Else VersionWindows = "Windows Server*2016" & "-" & Bytes End If End Select If InStr(Os.szCSDVersion, Chr(0)) > 0 Then Sp = Left(Os.szCSDVersion, InStr(Os.szCSDVersion, Chr(0)) - 1) End If Forms!AProposDe!WinVer = VersionWindows & " " & Sp End Function
Partager