Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Bonjour à tous,
j'ai essayé un script glané d'ici ou d'ailleurs pour récupérer la version de l'OS sur lequel tourne mon application (voir plus bas)
Le problème c'est qu'il ne fait pas de distinction lorsque je suis sur un Windows Xp ou un Vista.
dans tous les cas la variable OSMajorRevision vaut 5.
je travaille avec Powerbuilder 10.5.1 et le problème se pose sur un Vista professionnel tournant sur un serveur VmWare (je ne sais pas si cela aurait une
incidence, ce que je ne pense pas mais bon...)
Quelqu'un aurait une idée ou une solution à ce problème
Merci à tous
Vincent
Environment le_env String ls_osversion GetEnvironment(le_env) If le_env.OSType = WindowsNT! Then choose case le_env.OSMajorRevision case 5 choose case le_env.OSMinorRevision case 0 ls_osversion = "Windows 2000" case 1 ls_osversion = "Windows XP" case 2 ls_osversion = "Windows 2003" case else ls_osversion = "Windows " ls_osversion += String(le_env.OSMajorRevision) + "." ls_osversion += String(le_env.OSMinorRevision) end choose case 6 ls_osversion = "Windows Vista" case else ls_osversion = "Windows NT " ls_osversion += String(le_env.OSMajorRevision) + "." ls_osversion += String(le_env.OSMinorRevision) end choose Else If le_env.OSMajorRevision = 4 Then If le_env.OSMinorRevision = 10 Then ls_osversion = "Windows 98" Else ls_osversion = "Windows 95" End If Else ls_osversion = "Windows 3." + String(le_env.OSMinorRevision) End If End If
Hors ligne
Bonsoir, j'ai trouvé ça en VB :
Option Explicit 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 Type OSVERSIONINFOEX dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 wServicePackMajor As Integer wServicePackMinor As Integer wSuiteMask As Integer wProductType As Byte wReserved As Byte End Type Private Type SYSTEM_INFO wProcessorArchitecture As Integer wReserved As Integer dwPageSize As Long lpMinimumApplicationAddress As Long lpMaximumApplicationAddress As Long dwActiveProcessorMask As Long dwNumberOrfProcessors As Long dwProcessorType As Long dwAllocationGranularity As Long dwReserved As Long End Type Private Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (ByRef lpVersionInformation As Any) As Long Private Declare Sub GetSystemInfo Lib "kernel32.dll" (ByRef lpSystemInfo As SYSTEM_INFO) Private Declare Sub GetNativeSystemInfo Lib "kernel32.dll" (ByRef lpSystemInfo As SYSTEM_INFO) Private Declare Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long Private Declare Function GetProcAddress Lib "kernel32.dll" (ByVal hModule As Long, ByVal lpProcName As String) As Long Private Declare Function GetProductInfo Lib "kernel32.dll" (ByVal dwOSMajorVersion As Long, ByVal dwOSMinorVersion As Long, ByVal dwSpMajorVersion As Long, ByVal dwSpMinorVersion As Long, ByRef pdwReturnedProductType As Long) As Long Private Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long Private Const SM_SERVERR2 As Long = 89 Private Const VER_PLATFORM_WIN32_NT As Long = 2 Private Const VER_PLATFORM_WIN32_WINDOWS As Long = 1 Private Const VER_PLATFORM_WIN32s As Long = 0 Private Const VER_PLATFORMID As Long = &H8 Private Const VER_PRERELEASE As Long = 0 Private Const VS_FF_PRIVATEBUILD As Long = &H8& Private Const VER_PRIVATEBUILD As Long = VS_FF_PRIVATEBUILD Private Const VER_PRODUCT_TYPE As Long = &H80 Private Const VER_PRODUCTBETA_STR As String = "" Private Const VER_PRODUCTBUILD As Long = 1000 Private Const VER_PRODUCTBUILD_QFE As Long = 1 Private Const VER_PRODUCTNAME_STR As String = "Platform SDK Sample Code" Private Const VER_PRODUCTVERSION_DW As Long = (&H1000000 Or VER_PRODUCTBUILD) Private Const VER_PRODUCTVERSION_STRING As String = "1.00" Private Const VER_PRODUCTVERSION_W As Long = &H100 Private Const VER_SERVER_NT As Long = &H80000000 Private Const VER_SERVICEPACKMAJOR As Long = &H20 Private Const VER_SERVICEPACKMINOR As Long = &H10 Private Const PROCESSOR_ARCHITECTURE_AMD64 As Long = 9 Private Const PROCESSOR_ARCHITECTURE_ALPHA As Long = 2 Private Const PROCESSOR_ARCHITECTURE_ALPHA64 As Long = 7 Private Const PROCESSOR_ARCHITECTURE_ARM As Long = 5 Private Const PROCESSOR_ARCHITECTURE_IA64 As Long = 6 Private Const PROCESSOR_ARCHITECTURE_INTEL As Long = 0 Private Const PROCESSOR_ARCHITECTURE_MIPS As Long = 1 Private Const PROCESSOR_ARCHITECTURE_MSIL As Long = 8 Private Const PROCESSOR_ARCHITECTURE_PPC As Long = 3 Private Const PROCESSOR_ARCHITECTURE_UNKNOWN As Long = &HFFFF& Private Const VER_SUITE_BACKOFFICE As Long = &H4 Private Const VER_SUITE_COMMUNICATIONS As Long = &H8 Private Const VER_SUITE_DATACENTER As Long = &H80 Private Const VER_SUITE_EMBEDDEDNT As Long = &H40 Private Const VER_SUITE_ENTERPRISE As Long = &H2 Private Const VER_SUITE_SINGLEUSERTS As Long = &H100 Private Const VER_SUITE_PERSONAL As Long = &H200 Private Const VER_SUITE_BLADE As Long = &H400 Private Const VER_SUITE_COMPUTE_SERVER As Long = &H4000 Private Const VER_SUITE_STORAGE_SERVER As Long = &H2000 Private Const VER_SUITE_SMALLBUSINESS As Long = &H1 Private Const VER_SUITE_SMALLBUSINESS_RESTRICTED As Long = &H20 Private Const VER_SUITE_TERMINAL As Long = &H10 Private Const VER_SUITENAME As Long = &H40 Private Const VER_NT_DOMAIN_CONTROLLER As Long = &H2 Private Const VER_NT_SERVER As Long = &H3 Private Const VER_NT_WORKSTATION As Long = &H1 Private Const PRODUCT_BUSINESS_N As Long = &H10 Private Const PRODUCT_BUSINESS As Long = &H6 Private Const PRODUCT_CLUSTER_SERVER As Long = &H12 Private Const PRODUCT_DATACENTER_SERVER As Long = &H8 Private Const PRODUCT_DATACENTER_SERVER_CORE As Long = &HC Private Const PRODUCT_DATACENTER_SERVER_CORE_V As Long = &H27 Private Const PRODUCT_DATACENTER_SERVER_V As Long = &H25 Private Const PRODUCT_ENTERPRISE As Long = &H4 Private Const PRODUCT_ENTERPRISE_N As Long = &H1B Private Const PRODUCT_ENTERPRISE_SERVER As Long = &HA Private Const PRODUCT_ENTERPRISE_SERVER_CORE As Long = &HE Private Const PRODUCT_ENTERPRISE_SERVER_CORE_V As Long = &H29 Private Const PRODUCT_ENTERPRISE_SERVER_IA64 As Long = &HF Private Const PRODUCT_ENTERPRISE_SERVER_V As Long = &H26 Private Const PRODUCT_HOME_BASIC As Long = &H2 Private Const PRODUCT_HOME_BASIC_N As Long = &H5 Private Const PRODUCT_HOME_PREMIUM As Long = &H3 Private Const PRODUCT_HOME_PREMIUM_N As Long = &H1A Private Const PRODUCT_HOME_SERVER As Long = &H13 Private Const PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT As Long = &H1E Private Const PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING As Long = &H20 Private Const PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY As Long = &H1F Private Const PRODUCT_SERVER_FOR_SMALLBUSINESS As Long = &H18 Private Const PRODUCT_SMALLBUSINESS_SERVER As Long = &H9 Private Const PRODUCT_SMALLBUSINESS_SERVER_PREMIUM As Long = &H19 Private Const PRODUCT_STANDARD_SERVER As Long = &H7 Private Const PRODUCT_STANDARD_SERVER_CORE As Long = &HD Private Const PRODUCT_STANDARD_SERVER_CORE_V As Long = &H28 Private Const PRODUCT_STANDARD_SERVER_V As Long = &H24 Private Const PRODUCT_STARTER As Long = &HB Private Const PRODUCT_STORAGE_ENTERPRISE_SERVER As Long = &H17 Private Const PRODUCT_STORAGE_EXPRESS_SERVER As Long = &H14 Private Const PRODUCT_STORAGE_STANDARD_SERVER As Long = &H15 Private Const PRODUCT_STORAGE_WORKGROUP_SERVER As Long = &H16 Private Const PRODUCT_ULTIMATE As Long = &H1 Private Const PRODUCT_ULTIMATE_N As Long = &H1C Private Const PRODUCT_UNDEFINED As Long = &H0 Private Const PRODUCT_WEB_SERVER As Long = &H11 Private Const PRODUCT_WEB_SERVER_CORE As Long = &H1D Public Function GetOSDisplayString() As String Dim osvi As OSVERSIONINFOEX Dim si As SYSTEM_INFO Dim bOsVersionInfoEx As Boolean Dim dwType As Long Dim sBuffer As String osvi.dwOSVersionInfoSize = Len(osvi) If GetVersionEx(osvi) Then '# Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. If GetProcAddress(GetModuleHandle("kernel32.dll"), "GetNativeSystemInfo") <> 0 Then GetNativeSystemInfo si Else GetSystemInfo si End If If (VER_PLATFORM_WIN32_NT = osvi.dwPlatformId And osvi.dwMajorVersion > 4) Then sBuffer = "Microsoft " '# Test for the specific product. If osvi.dwMajorVersion = 6 And osvi.dwMinorVersion = 0 Then If osvi.wProductType = VER_NT_WORKSTATION Then sBuffer = sBuffer & "Windows Vista " Else sBuffer = sBuffer & "Windows Server 2008 " End If GetProductInfo 6, 0, 0, 0, dwType Select Case dwType Case PRODUCT_ULTIMATE sBuffer = sBuffer & "Ultimate Edition" Case PRODUCT_HOME_PREMIUM sBuffer = sBuffer & "Home Premium Edition" Case PRODUCT_HOME_BASIC sBuffer = sBuffer & "Home Basic Edition" Case PRODUCT_ENTERPRISE sBuffer = sBuffer & "Enterprise Edition" Case PRODUCT_BUSINESS sBuffer = sBuffer & "Business Edition" Case PRODUCT_STARTER sBuffer = sBuffer & "Starter Edition" Case PRODUCT_CLUSTER_SERVER sBuffer = sBuffer & "Cluster Server Edition" Case PRODUCT_DATACENTER_SERVER sBuffer = sBuffer & "Datacenter Edition" Case PRODUCT_DATACENTER_SERVER_CORE sBuffer = sBuffer & "Datacenter Edition (core installation)" Case PRODUCT_ENTERPRISE_SERVER sBuffer = sBuffer & "Enterprise Edition" Case PRODUCT_ENTERPRISE_SERVER_CORE sBuffer = sBuffer & "Enterprise Edition (core installation)" Case PRODUCT_ENTERPRISE_SERVER_IA64 sBuffer = sBuffer & "Enterprise Edition for Itanium-based Systems" Case PRODUCT_SMALLBUSINESS_SERVER sBuffer = sBuffer & "Small Business Server" Case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM sBuffer = sBuffer & "Small Business Server Premium Edition" Case PRODUCT_STANDARD_SERVER sBuffer = sBuffer & "Standard Edition" Case PRODUCT_STANDARD_SERVER_CORE sBuffer = sBuffer & "Standard Edition (core installation)" Case PRODUCT_WEB_SERVER sBuffer = sBuffer & "Web Server Edition" End Select If si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 Then sBuffer = sBuffer & ", 64-bit" ElseIf si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL Then sBuffer = sBuffer & ", 32-bit" End If ElseIf osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 2 Then If GetSystemMetrics(SM_SERVERR2) Then sBuffer = sBuffer & "Windows Server 2003 R2, " ElseIf osvi.wSuiteMask = VER_SUITE_STORAGE_SERVER Then sBuffer = sBuffer & "Windows Storage Server 2003" ElseIf osvi.wProductType = VER_NT_WORKSTATION And si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 Then sBuffer = sBuffer & "Windows XP Professional x64 Edition" Else sBuffer = sBuffer & "Windows Server 2003, " End If '# Test for the server type. If osvi.wProductType <> VER_NT_WORKSTATION Then If si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64 Then If (osvi.wSuiteMask And VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER Then sBuffer = sBuffer & "Datacenter Edition for Itanium-based Systems" ElseIf (osvi.wSuiteMask And VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE Then sBuffer = sBuffer & "Enterprise Edition for Itanium-based Systems" End If ElseIf si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 Then If (osvi.wSuiteMask And VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER Then sBuffer = sBuffer & "Datacenter x64 Edition" ElseIf (osvi.wSuiteMask And VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE Then sBuffer = sBuffer & "Enterprise x64 Edition" Else sBuffer = sBuffer & "Standard x64 Edition" End If Else If (osvi.wSuiteMask And VER_SUITE_COMPUTE_SERVER) = VER_SUITE_COMPUTE_SERVER Then sBuffer = sBuffer & "Compute Cluster Edition" ElseIf (osvi.wSuiteMask And VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER Then sBuffer = sBuffer & "Datacenter Edition" ElseIf (osvi.wSuiteMask And VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE Then sBuffer = sBuffer & "Enterprise Edition" ElseIf (osvi.wSuiteMask And VER_SUITE_BLADE) = VER_SUITE_BLADE Then sBuffer = sBuffer & "Web Edition" Else sBuffer = sBuffer & "Standard Edition" End If End If End If ElseIf osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 1 Then sBuffer = sBuffer & "Windows XP " If (osvi.wSuiteMask And VER_SUITE_PERSONAL) = VER_SUITE_PERSONAL Then sBuffer = sBuffer & "Home Edition" Else sBuffer = sBuffer & "Professional" End If ElseIf osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 0 Then sBuffer = sBuffer & "Windows 2000 " If osvi.wProductType = VER_NT_WORKSTATION Then sBuffer = sBuffer & "Professional" Else If (osvi.wSuiteMask And VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER Then sBuffer = sBuffer & "Datacenter Server" ElseIf (osvi.wSuiteMask And VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE Then sBuffer = sBuffer & "Advanced Server" Else sBuffer = sBuffer & "Server" End If End If End If '# Include service pack (if any) and build number. sBuffer = sBuffer & " " & osvi.szCSDVersion sBuffer = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1) sBuffer = sBuffer & " (build " & osvi.dwBuildNumber & ")" End If Else End If GetOSDisplayString = sBuffer End Function
Hors ligne
Thx erasorz pour la réponse:
J'ai effectivement aussi essayé avec la fonction GetVersionEx mais apparement rien n'y fait.
Il me renvoit toujours 5 comme valeur de OSMajorRevision alors que dans l'aide de
Microsoft, il devrait me renvoyer 6.
peut-être est-ce lié au fait que l'application se trouve sur un serveur Vmware, ce qui serait
fortement désagréable..
Je vais un peu investiguer de ce côté..
Vincent
Hors ligne
Je confirme bien, ce n'est pas un problème lié à VmWare.
Je viens de faire un SELECT @@VERSION dans SQL Server installé sur le poste Vista
et il me renvois bien la version NT 6 et non la 5 comme avec toutes les fonctions que j'ai
essayées précédement. Je pense qu'il existe probablement une nouvelle fonction qui permet
de récupérer cette version sous Vista, j'investigue...
Vincent
Hors ligne
J'ai trouvé le problème:
L'application que je lance est en mode compatibilité XP et il semblerait que la fonction GetVersionEx se base sur l'OS Compatible plutôt que
sur l'OS véritable. (Etrange).
J'ai malgré tout trouvé une autre piste qui me permettra de récupérer la version de l'OS:
Une clé dans la registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
Vincent
Hors ligne
Bonjour,
Je viens d'adapter mon application sous windows vista.
Je teste également la version du système d'exploitation pour réaliser des opérations différentes en fonction du système d'exploitation (ex: ne pas essayer d'écrire dans C:\Program Files sous VISTA mais dans C:\ProgramData)
J'ai mis en place le même code PB (PB 11.2.8616) que le tient. J'ai bien une valeur de 6 pour windows vista ( et également vista sous virtual PC 2007).
je te propose une autre manière de déterminer le système d'exploitation en utilisant la fonction de l'API SHGetFolderPath qui retourne les chemins sur les dossiers spéciaux de Windows :
// Récupérer les informations sur les dossiers spéciaux de windows FUNCTION ulong SHGetFolderPath(ulong hwndOwner, int nFolder, ulong hToken, long dwFlags, ref string pszPath) LIBRARY "shell32.dll" ALIAS FOR "SHGetFolderPathA;Ansi" .... ulong lul_buffer = 256, lul_null, lul_ret SetNull(lul_null) as_pszpath = Space(lul_buffer) // Attention, réserver la place pour le retour sinon GPF lul_ret = SHGetFolderPath(lul_null, 35, lul_null, 1, as_pszpath)
as_pszpath = C:\Documents and Settings\All Users\Application Data => Windows XP et précédent
as_pszpath = C:\ProgramData => Windows Vista
Tu as répondu pendant que je rédigeais ma réponse. On risque d'avoir le même problème si l'application s'exécute en mode compatibilité XP.
Hors ligne
Bonjour à tous
J'ai traduit le code VB donné par Erasorz :
J'ai testé sur différents OS et ça à l'air de bien marcher.
//#################################################################### //############ STRUCTURES ######################################## //#################################################################### global type str_system_info from structure Integer wProcessorArchitecture Integer wReserved Long dwPageSize Long lpMinimumApplicationAddress Long lpMaximumApplicationAddress Long dwActiveProcessorMask Long dwNumberOrfProcessors Long dwProcessorType Long dwAllocationGranularity Long dwReserved end type global type str_osversioninfoex from structure unsignedlong dwosversioninfosize unsignedlong dwmajorversion unsignedlong dwminorversion unsignedlong dwbuildnumber unsignedlong dwplatformid character szcsdversion[64] unsignedinteger wservicepackmajor unsignedinteger wservicepackminor unsignedinteger wsuitemask byte wproducttype byte wreserved end type //#################################################################### //############ External FUNCTIONS ############################### //#################################################################### FUNCTION long GetVersionExA(Ref str_OSVERSIONINFOEX lpVersionInformation) Library "kernel32.dll" FUNCTION Long GetProcAddress(Long hModule, String lpProcName) LIBRARY "Kernel32.dll" FUNCTION Long GetModuleHandle(String lpModuleName) LIBRARY "Kernel32.dll" Alias for "GetModuleHandleA;Ansi" SUBROUTINE GetSystemInfo(Ref str_SYSTEM_INFO lpSystemInfo) LIBRARY "Kernel32.dll" SUBROUTINE GetNativeSystemInfo(Ref str_SYSTEM_INFO lpSystemInfo) LIBRARY "Kernel32.dll" FUNCTION Long GetProductInfo(Long dwOSMajorVersion, Long dwOSMinorVersion, Long dwSpMajorVersion, Long dwSpMinorVersion, Ref Long pdwReturnedProductType) LIBRARY "Kernel32.dll" FUNCTION Integer GetSystemMetrics (Integer nIndex) LIBRARY "user32.dll" //#################################################################### //############ FUNCTIONS ######################################## //#################################################################### //############################################################################# //public function long ark_bitand (long al_1, long al_2); // Overloaded long ll_values[2] ll_values[1] = al_1 ll_values[2] = al_2 return ark_bitand(ll_values) end function //############################################################################# //public function long ark_bitand (long la_values[]); integer li_Bit, li_Size, li_Number = 2 long ll_RetValue, ll_ValueA, ll_ValueB li_Size = UpperBound(la_values) If li_Size < 2 Then MessageBox("Error","This function needs 2 values!",StopSign!,Ok!) Return(-1) End If ll_RetValue = 0 ll_ValueA = la_values[1] Do ll_ValueB = la_values[li_Number] For li_Bit = 0 To 31 If Mod(Long(ll_ValueA / 2^li_Bit), 2) > 0 And Mod(Long(ll_ValueB / 2^li_Bit), 2) > 0 Then If Not Mod(Long(ll_RetValue / 2^li_Bit), 2) > 0 then ll_RetValue += 2^li_Bit End If End If Next ll_ValueA = ll_RetValue li_Number++ Loop Until li_Number > li_Size Return(ll_RetValue) //############################################################################# //public function long ark_bitor (long al_values[]);integer li_Bit, li_Size, li_Number = 2 long ll_RetValue, ll_ValueA, ll_ValueB li_Size = UpperBound(al_Values) If li_Size < 2 Then MessageBox("Error","This function needs 2 values!",StopSign!,Ok!) Return(-1) End If ll_RetValue = 0 ll_ValueA = al_Values[1] Do ll_ValueB = al_Values[li_Number] For li_Bit = 0 To 31 If Mod(Long(ll_ValueA / 2^li_Bit), 2) > 0 Or Mod(Long(ll_ValueB / 2^li_Bit), 2) > 0 Then If Not Mod(Long(ll_RetValue / 2^li_Bit), 2) > 0 then ll_RetValue += 2^li_Bit End If End If Next ll_ValueA = ll_RetValue li_Number++ Loop Until li_Number > li_Size return ll_RetValue //############################################################################# //public function string os_version () constant long SM_SERVERR2= 89 constant long VER_PLATFORM_WIN32_NT= 2 constant long VER_PLATFORM_WIN32_WINDOWS= 1 constant long VER_PLATFORM_WIN32s= 0 constant long VER_PLATFORMID= 8 constant long VER_PRERELEASE= 0 constant long VS_FF_PRIVATEBUILD= 8 constant long VER_PRIVATEBUILD= 0 // VS_FF_PRIVATEBUILD constant long VER_PRODUCT_TYPE= 128 constant string VER_PRODUCTBETA_STR="" constant long VER_PRODUCTBUILD= 1000 constant long VER_PRODUCTBUILD_QFE= 1 constant string VER_PRODUCTNAME_STR="Platform SDK Sample Code" constant long VER_PRODUCTVERSION_DW=16777216 // Or VER_PRODUCTBUILD constant string VER_PRODUCTVERSION_STRING= "1.00" constant long VER_PRODUCTVERSION_W= 256 constant long VER_SERVER_NT= 2147483648 constant long VER_SERVICEPACKMAJOR= 32 constant long VER_SERVICEPACKMINOR= 16 constant long PROCESSOR_ARCHITECTURE_AMD64= 9 constant long PROCESSOR_ARCHITECTURE_ALPHA= 2 constant long PROCESSOR_ARCHITECTURE_ALPHA64= 7 constant long PROCESSOR_ARCHITECTURE_ARM= 5 constant long PROCESSOR_ARCHITECTURE_IA64= 6 constant long PROCESSOR_ARCHITECTURE_INTEL= 0 constant long PROCESSOR_ARCHITECTURE_MIPS= 1 constant long PROCESSOR_ARCHITECTURE_MSIL= 8 constant long PROCESSOR_ARCHITECTURE_PPC= 3 constant long PROCESSOR_ARCHITECTURE_UNKNOWN= 65535 constant long VER_SUITE_BACKOFFICE= 4 constant long VER_SUITE_COMMUNICATIONS= 8 constant long VER_SUITE_DATACENTER= 128 constant long VER_SUITE_EMBEDDEDNT= 64 constant long VER_SUITE_ENTERPRISE= 2 constant long VER_SUITE_SINGLEUSERTS= 256 constant long VER_SUITE_PERSONAL= 512 constant long VER_SUITE_BLADE= 1024 constant long VER_SUITE_COMPUTE_SERVER= 16384 constant long VER_SUITE_STORAGE_SERVER= 8192 constant long VER_SUITE_SMALLBUSINESS= 1 constant long VER_SUITE_SMALLBUSINESS_RESTRICTED= 32 constant long VER_SUITE_TERMINAL= 16 constant long VER_SUITENAME= 64 constant long VER_NT_DOMAIN_CONTROLLER= 2 constant long VER_NT_SERVER= 3 constant long VER_NT_WORKSTATION= 1 constant long PRODUCT_BUSINESS_N= 16 constant long PRODUCT_BUSINESS= 6 constant long PRODUCT_CLUSTER_SERVER= 18 constant long PRODUCT_DATACENTER_SERVER= 8 constant long PRODUCT_DATACENTER_SERVER_CORE= 12 constant long PRODUCT_DATACENTER_SERVER_CORE_V= 39 constant long PRODUCT_DATACENTER_SERVER_V= 37 constant long PRODUCT_ENTERPRISE= 4 constant long PRODUCT_ENTERPRISE_N= 27 constant long PRODUCT_ENTERPRISE_SERVER= 10 constant long PRODUCT_ENTERPRISE_SERVER_CORE= 15 constant long PRODUCT_ENTERPRISE_SERVER_CORE_V= 41 constant long PRODUCT_ENTERPRISE_SERVER_IA64= 15 constant long PRODUCT_ENTERPRISE_SERVER_V= 38 constant long PRODUCT_HOME_BASIC= 2 constant long PRODUCT_HOME_BASIC_N= 9 constant long PRODUCT_HOME_PREMIUM= 3 constant long PRODUCT_HOME_PREMIUM_N= 26 constant long PRODUCT_HOME_SERVER= 19 constant long PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT= 30 constant long PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING= 32 constant long PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY= 31 constant long PRODUCT_SERVER_FOR_SMALLBUSINESS= 24 constant long PRODUCT_SMALLBUSINESS_SERVER= 9 constant long PRODUCT_SMALLBUSINESS_SERVER_PREMIUM= 25 constant long PRODUCT_STANDARD_SERVER= 7 constant long PRODUCT_STANDARD_SERVER_CORE = 13 constant long PRODUCT_STANDARD_SERVER_CORE_V= 40 constant long PRODUCT_STANDARD_SERVER_V= 36 constant long PRODUCT_STARTER= 11 constant long PRODUCT_STORAGE_ENTERPRISE_SERVER= 23 constant long PRODUCT_STORAGE_EXPRESS_SERVER= 20 constant long PRODUCT_STORAGE_STANDARD_SERVER= 21 constant long PRODUCT_STORAGE_WORKGROUP_SERVER= 22 constant long PRODUCT_ULTIMATE= 1 constant long PRODUCT_ULTIMATE_N= 28 constant long PRODUCT_UNDEFINED= 0 constant long PRODUCT_WEB_SERVER= 17 constant long PRODUCT_WEB_SERVER_CORE= 29 str_OSVERSIONINFOEX osvi str_SYSTEM_INFO si string ls_os, ls_sp string ls_os_version boolean lb_OsVersionInfoEx long ll_dwType string ls_Buffer osvi.dwOSVersionInfoSize = 156 //Len(osvi) If GetVersionExA(osvi) <> 0 Then //# Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. If GetProcAddress(GetModuleHandle("kernel32.dll"), "GetNativeSystemInfo") <> 0 Then GetNativeSystemInfo(si) Else GetSystemInfo(si) End If If (VER_PLATFORM_WIN32_NT = osvi.dwPlatformId And osvi.dwMajorVersion > 4) Then ls_Buffer = "Microsoft " //# Test for the specific product. If osvi.dwMajorVersion = 6 And osvi.dwMinorVersion = 0 Then If osvi.wProductType = VER_NT_WORKSTATION Then ls_Buffer = ls_Buffer + "Windows Vista " Else ls_Buffer = ls_Buffer + "Windows Server 2008 " End If if GetProductInfo( osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.wservicepackmajor, osvi.wservicepackminor, ll_dwType) > 0 then choose Case ll_dwType Case PRODUCT_ULTIMATE ls_Buffer = ls_Buffer + "Ultimate Edition" Case PRODUCT_HOME_PREMIUM ls_Buffer = ls_Buffer + "Home Premium Edition" Case PRODUCT_HOME_BASIC ls_Buffer = ls_Buffer + "Home Basic Edition" Case PRODUCT_ENTERPRISE ls_Buffer = ls_Buffer + "Enterprise Edition" Case PRODUCT_BUSINESS ls_Buffer = ls_Buffer + "Business Edition" Case PRODUCT_STARTER ls_Buffer = ls_Buffer + "Starter Edition" Case PRODUCT_CLUSTER_SERVER ls_Buffer = ls_Buffer + "Cluster Server Edition" Case PRODUCT_DATACENTER_SERVER ls_Buffer = ls_Buffer + "Datacenter Edition" Case PRODUCT_DATACENTER_SERVER_CORE ls_Buffer = ls_Buffer + "Datacenter Edition (core installation)" Case PRODUCT_ENTERPRISE_SERVER ls_Buffer = ls_Buffer + "Enterprise Edition" Case PRODUCT_ENTERPRISE_SERVER_CORE ls_Buffer = ls_Buffer + "Enterprise Edition (core installation)" Case PRODUCT_ENTERPRISE_SERVER_IA64 ls_Buffer = ls_Buffer + "Enterprise Edition for Itanium-based Systems" Case PRODUCT_SMALLBUSINESS_SERVER ls_Buffer = ls_Buffer + "Small Business Server" Case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM ls_Buffer = ls_Buffer + "Small Business Server Premium Edition" Case PRODUCT_STANDARD_SERVER ls_Buffer = ls_Buffer + "Standard Edition" Case PRODUCT_STANDARD_SERVER_CORE ls_Buffer = ls_Buffer + "Standard Edition (core installation)" Case PRODUCT_WEB_SERVER ls_Buffer = ls_Buffer + "Web Server Edition" End choose else ls_Buffer = ls_Buffer + "type non trouvé" end if If si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 Then ls_Buffer = ls_Buffer + ", 64-bit" ElseIf si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL Then ls_Buffer = ls_Buffer + ", 32-bit" End If ElseIf osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 2 Then If GetSystemMetrics(SM_SERVERR2)=0 Then ls_Buffer = ls_Buffer + "Windows Server 2003 R2, " ElseIf osvi.wSuiteMask = VER_SUITE_STORAGE_SERVER Then ls_Buffer = ls_Buffer + "Windows Storage Server 2003" ElseIf osvi.wProductType = VER_NT_WORKSTATION And si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 Then ls_Buffer = ls_Buffer + "Windows XP Professional x64 Edition" Else ls_Buffer = ls_Buffer + "Windows Server 2003, " End If //# Test for the server type. If osvi.wProductType <> VER_NT_WORKSTATION Then If si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64 Then If ark_bitand(osvi.wSuiteMask, VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER Then ls_Buffer = ls_Buffer + "Datacenter Edition for Itanium-based Systems" ElseIf ark_bitand(osvi.wSuiteMask, VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE Then ls_Buffer = ls_Buffer + "Enterprise Edition for Itanium-based Systems" End If ElseIf si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 Then If ark_bitand(osvi.wSuiteMask, VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER Then ls_Buffer = ls_Buffer + "Datacenter x64 Edition" ElseIf ark_bitand(osvi.wSuiteMask, VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE Then ls_Buffer = ls_Buffer + "Enterprise x64 Edition" Else ls_Buffer = ls_Buffer + "Standard x64 Edition" End If Else If ark_bitand(osvi.wSuiteMask, VER_SUITE_COMPUTE_SERVER) = VER_SUITE_COMPUTE_SERVER Then ls_Buffer = ls_Buffer + "Compute Cluster Edition" ElseIf ark_bitand(osvi.wSuiteMask, VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER Then ls_Buffer = ls_Buffer + "Datacenter Edition" ElseIf ark_bitand(osvi.wSuiteMask, VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE Then ls_Buffer = ls_Buffer + "Enterprise Edition" ElseIf ark_bitand(osvi.wSuiteMask, VER_SUITE_BLADE) = VER_SUITE_BLADE Then ls_Buffer = ls_Buffer + "Web Edition" Else ls_Buffer = ls_Buffer + "Standard Edition" End If End If End If ElseIf osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 1 Then ls_Buffer = ls_Buffer + "Windows XP " If ark_bitand(osvi.wSuiteMask, VER_SUITE_PERSONAL) = VER_SUITE_PERSONAL Then ls_Buffer = ls_Buffer + "Home Edition" Else ls_Buffer = ls_Buffer + "Professional" End If ElseIf osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 0 Then ls_Buffer = ls_Buffer + "Windows 2000 " If osvi.wProductType = VER_NT_WORKSTATION Then ls_Buffer = ls_Buffer + "Professional" Else If ark_bitand(osvi.wSuiteMask,VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER Then ls_Buffer = ls_Buffer + "Datacenter Server" ElseIf ark_bitand(osvi.wSuiteMask,VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE Then ls_Buffer = ls_Buffer + "Advanced Server" Else ls_Buffer = ls_Buffer + "Server" End If End If End If //# Include service pack (if any) ls_Buffer = ls_Buffer + " " + string(blob(osvi.szCSDVersion), EncodingANSI!) //# Include build number. ls_Buffer = ls_Buffer + " (build " + string(osvi.dwBuildNumber) + ")" End If End If return ls_os_version
Dernière modification par arkiane (19-12-2008 13:13:47)
Hors ligne
bcp pour le retour
00.000 pépites
NB :
Hors ligne
Bonjour,
J'utilise le code de arkiane, mais j'ai il ne fonctionne pas pour SEVEN et les serveur 2008 R2
Quelles sont les valeur osvi.dwMajorVersion et osvi.dwMinorVersion utilisé pour ces systèmes ?
A très +
Hors ligne
Hors ligne
Merci,
Ci dessous le code actualisé pour ma fonction "of_GetOSVersion(ref string as_OSLibelle) returns string"
string ls_OSVersion str_SYSTEM_INFO SystemInfo str_OSVERSIONINFOEX osVI osVI.dwOSVersionInfoSize = 156 // Len(osVI) IF GetVersionExA(osvi) <> 0 THEN // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. IF GetProcAddress(GetModuleHandle("kernel32.dll"),"GetNativeSystemInfo") <> 0 THEN GetNativeSystemInfo(SystemInfo) ELSE GetSystemInfo(SystemInfo) END IF // Test for the specific product. IF VER_PLATFORM_WIN32_NT=osVI.dwPlatformId AND osVI.dwMajorVersion > 4 THEN as_OSLibelle = "Microsoft " IF osVI.dwMajorVersion = 6 AND osVI.dwMinorVersion = 1 THEN IF osVI.wProductType = VER_NT_WORKSTATION THEN ls_OSVersion = "Windows SEVEN" ELSE ls_OSVersion = "Windows Server 2008 R2" END IF as_OSLibelle+= ls_OSVersion ELSEIF osVI.dwMajorVersion = 6 AND osVI.dwMinorVersion = 0 THEN IF osVI.wProductType = VER_NT_WORKSTATION THEN ls_OSVersion = "Windows Vista" ELSE ls_OSVersion = "Windows Server 2008" END IF as_OSLibelle+= ls_OSVersion long ll_dwType IF GetProductInfo(osVI.dwMajorVersion,osVI.dwMinorVersion,osVI.wservicepackmajor,osVI.wservicepackminor,ll_dwType) > 0 THEN CHOOSE CASE ll_dwType CASE PRODUCT_ULTIMATE as_OSLibelle+= " Ultimate Edition" CASE PRODUCT_HOME_PREMIUM as_OSLibelle+= " Home Premium Edition" CASE PRODUCT_HOME_BASIC as_OSLibelle+= " Home Basic Edition" CASE PRODUCT_ENTERPRISE as_OSLibelle+= " Enterprise Edition" CASE PRODUCT_BUSINESS as_OSLibelle+= " Business Edition" CASE PRODUCT_STARTER as_OSLibelle+= " Starter Edition" CASE PRODUCT_CLUSTER_SERVER as_OSLibelle+= " Cluster Server Edition" CASE PRODUCT_DATACENTER_SERVER as_OSLibelle+= " Datacenter Edition" CASE PRODUCT_DATACENTER_SERVER_CORE as_OSLibelle+= " Datacenter Edition (core installation)" CASE PRODUCT_ENTERPRISE_SERVER as_OSLibelle+= " Enterprise Edition" CASE PRODUCT_ENTERPRISE_SERVER_CORE as_OSLibelle+= " Enterprise Edition (core installation)" CASE PRODUCT_ENTERPRISE_SERVER_IA64 as_OSLibelle+= " Enterprise Edition for Itanium-based Systems" CASE PRODUCT_SMALLBUSINESS_SERVER as_OSLibelle+= " Small Business Server" CASE PRODUCT_SMALLBUSINESS_SERVER_PREMIUM as_OSLibelle+= " Small Business Server Premium Edition" CASE PRODUCT_STANDARD_SERVER as_OSLibelle+= " Standard Edition" CASE PRODUCT_STANDARD_SERVER_CORE as_OSLibelle+= " Standard Edition (core installation)" CASE PRODUCT_WEB_SERVER as_OSLibelle+= " Web Server Edition" END CHOOSE ELSE // as_OSLibelle+= "type non trouvé" END IF IF SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 THEN as_OSLibelle+= " 64-bit" ELSEIF SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL THEN as_OSLibelle+= " 32-bit" END IF ELSEIF osVI.dwMajorVersion = 5 AND osVI.dwMinorVersion = 2 THEN IF GetSystemMetrics(SM_SERVERR2)=0 THEN ls_OSVersion = "Windows Server 2003 R2" ELSEIF osVI.wSuiteMask = VER_SUITE_STORAGE_SERVER THEN ls_OSVersion = "Windows Storage Server 2003" ELSEIF osVI.wProductType = VER_NT_WORKSTATION AND SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 THEN ls_OSVersion = "Windows XP Professional x64 Edition" ELSE ls_OSVersion = "Windows Server 2003" END IF as_OSLibelle+= ls_OSVersion // - Test for the server type. IF osVI.wProductType <> VER_NT_WORKSTATION THEN IF SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64 THEN IF ark_bitand(osVI.wSuiteMask,VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER THEN as_OSLibelle+= " Datacenter Edition for Itanium-based Systems" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE THEN as_OSLibelle+= " Enterprise Edition for Itanium-based Systems" END IF ELSEIF SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 THEN IF ark_bitand(osVI.wSuiteMask,VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER THEN as_OSLibelle+= " Datacenter x64 Edition" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE THEN as_OSLibelle+= " Enterprise x64 Edition" ELSE as_OSLibelle+= " Standard x64 Edition" END IF ELSE IF ark_bitand(osVI.wSuiteMask,VER_SUITE_COMPUTE_SERVER) = VER_SUITE_COMPUTE_SERVER THEN as_OSLibelle+= " Compute Cluster Edition" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER THEN as_OSLibelle+= " Datacenter Edition" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE THEN as_OSLibelle+= " Enterprise Edition" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_BLADE) = VER_SUITE_BLADE THEN as_OSLibelle+= " Web Edition" ELSE as_OSLibelle+= " Standard Edition" END IF END IF END IF ELSEIF osVI.dwMajorVersion = 5 AND osVI.dwMinorVersion = 1 THEN ls_OSVersion = "Windows XP" as_OSLibelle+= ls_OSVersion IF ark_bitand(osVI.wSuiteMask,VER_SUITE_PERSONAL) = VER_SUITE_PERSONAL THEN as_OSLibelle+= " Home Edition" ELSE as_OSLibelle+= " Professional" END IF ELSEIF osVI.dwMajorVersion = 5 AND osVI.dwMinorVersion = 0 THEN ls_OSVersion = "Windows 2000" as_OSLibelle+= ls_OSVersion IF osVI.wProductType = VER_NT_WORKSTATION THEN as_OSLibelle+= " Professional" ELSE IF ark_bitand(osVI.wSuiteMask,VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER THEN as_OSLibelle+= " Datacenter Server" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE THEN as_OSLibelle+= " Advanced Server" ELSE as_OSLibelle+= " Server" END IF END IF ELSE ls_OSVersion = string(osVI.dwMajorVersion)+'.'+string(osVI.dwMinorVersion) as_OSLibelle+= ls_OSVersion END IF // Include service pack (IF any) as_OSLibelle+= " "+string(blob(osVI.szCSDVersion),EncodingANSI!) // Include build number. as_OSLibelle+= " (build "+string(osVI.dwBuildNumber)+")" END IF END IF RETURN ls_OSVersion
Hors ligne
Nosh40 a écrit:
Merci,
Ci dessous le code actualisé pour ma fonction "of_GetOSVersion(ref string as_OSLibelle) returns string"Code: pb
string ls_OSVersion str_SYSTEM_INFO SystemInfo str_OSVERSIONINFOEX osVI osVI.dwOSVersionInfoSize = 156 // Len(osVI) IF GetVersionExA(osvi) <> 0 THEN // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. IF GetProcAddress(GetModuleHandle("kernel32.dll"),"GetNativeSystemInfo") <> 0 THEN GetNativeSystemInfo(SystemInfo) ELSE GetSystemInfo(SystemInfo) END IF // Test for the specific product. IF VER_PLATFORM_WIN32_NT=osVI.dwPlatformId AND osVI.dwMajorVersion > 4 THEN as_OSLibelle = "Microsoft " IF osVI.dwMajorVersion = 6 AND osVI.dwMinorVersion = 1 THEN IF osVI.wProductType = VER_NT_WORKSTATION THEN ls_OSVersion = "Windows SEVEN" ELSE ls_OSVersion = "Windows Server 2008 R2" END IF as_OSLibelle+= ls_OSVersion ELSEIF osVI.dwMajorVersion = 6 AND osVI.dwMinorVersion = 0 THEN IF osVI.wProductType = VER_NT_WORKSTATION THEN ls_OSVersion = "Windows Vista" ELSE ls_OSVersion = "Windows Server 2008" END IF as_OSLibelle+= ls_OSVersion long ll_dwType IF GetProductInfo(osVI.dwMajorVersion,osVI.dwMinorVersion,osVI.wservicepackmajor,osVI.wservicepackminor,ll_dwType) > 0 THEN CHOOSE CASE ll_dwType CASE PRODUCT_ULTIMATE as_OSLibelle+= " Ultimate Edition" CASE PRODUCT_HOME_PREMIUM as_OSLibelle+= " Home Premium Edition" CASE PRODUCT_HOME_BASIC as_OSLibelle+= " Home Basic Edition" CASE PRODUCT_ENTERPRISE as_OSLibelle+= " Enterprise Edition" CASE PRODUCT_BUSINESS as_OSLibelle+= " Business Edition" CASE PRODUCT_STARTER as_OSLibelle+= " Starter Edition" CASE PRODUCT_CLUSTER_SERVER as_OSLibelle+= " Cluster Server Edition" CASE PRODUCT_DATACENTER_SERVER as_OSLibelle+= " Datacenter Edition" CASE PRODUCT_DATACENTER_SERVER_CORE as_OSLibelle+= " Datacenter Edition (core installation)" CASE PRODUCT_ENTERPRISE_SERVER as_OSLibelle+= " Enterprise Edition" CASE PRODUCT_ENTERPRISE_SERVER_CORE as_OSLibelle+= " Enterprise Edition (core installation)" CASE PRODUCT_ENTERPRISE_SERVER_IA64 as_OSLibelle+= " Enterprise Edition for Itanium-based Systems" CASE PRODUCT_SMALLBUSINESS_SERVER as_OSLibelle+= " Small Business Server" CASE PRODUCT_SMALLBUSINESS_SERVER_PREMIUM as_OSLibelle+= " Small Business Server Premium Edition" CASE PRODUCT_STANDARD_SERVER as_OSLibelle+= " Standard Edition" CASE PRODUCT_STANDARD_SERVER_CORE as_OSLibelle+= " Standard Edition (core installation)" CASE PRODUCT_WEB_SERVER as_OSLibelle+= " Web Server Edition" END CHOOSE ELSE // as_OSLibelle+= "type non trouvé" END IF IF SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 THEN as_OSLibelle+= " 64-bit" ELSEIF SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL THEN as_OSLibelle+= " 32-bit" END IF ELSEIF osVI.dwMajorVersion = 5 AND osVI.dwMinorVersion = 2 THEN IF GetSystemMetrics(SM_SERVERR2)=0 THEN ls_OSVersion = "Windows Server 2003 R2" ELSEIF osVI.wSuiteMask = VER_SUITE_STORAGE_SERVER THEN ls_OSVersion = "Windows Storage Server 2003" ELSEIF osVI.wProductType = VER_NT_WORKSTATION AND SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 THEN ls_OSVersion = "Windows XP Professional x64 Edition" ELSE ls_OSVersion = "Windows Server 2003" END IF as_OSLibelle+= ls_OSVersion // - Test for the server type. IF osVI.wProductType <> VER_NT_WORKSTATION THEN IF SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64 THEN IF ark_bitand(osVI.wSuiteMask,VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER THEN as_OSLibelle+= " Datacenter Edition for Itanium-based Systems" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE THEN as_OSLibelle+= " Enterprise Edition for Itanium-based Systems" END IF ELSEIF SystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 THEN IF ark_bitand(osVI.wSuiteMask,VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER THEN as_OSLibelle+= " Datacenter x64 Edition" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE THEN as_OSLibelle+= " Enterprise x64 Edition" ELSE as_OSLibelle+= " Standard x64 Edition" END IF ELSE IF ark_bitand(osVI.wSuiteMask,VER_SUITE_COMPUTE_SERVER) = VER_SUITE_COMPUTE_SERVER THEN as_OSLibelle+= " Compute Cluster Edition" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER THEN as_OSLibelle+= " Datacenter Edition" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE THEN as_OSLibelle+= " Enterprise Edition" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_BLADE) = VER_SUITE_BLADE THEN as_OSLibelle+= " Web Edition" ELSE as_OSLibelle+= " Standard Edition" END IF END IF END IF ELSEIF osVI.dwMajorVersion = 5 AND osVI.dwMinorVersion = 1 THEN ls_OSVersion = "Windows XP" as_OSLibelle+= ls_OSVersion IF ark_bitand(osVI.wSuiteMask,VER_SUITE_PERSONAL) = VER_SUITE_PERSONAL THEN as_OSLibelle+= " Home Edition" ELSE as_OSLibelle+= " Professional" END IF ELSEIF osVI.dwMajorVersion = 5 AND osVI.dwMinorVersion = 0 THEN ls_OSVersion = "Windows 2000" as_OSLibelle+= ls_OSVersion IF osVI.wProductType = VER_NT_WORKSTATION THEN as_OSLibelle+= " Professional" ELSE IF ark_bitand(osVI.wSuiteMask,VER_SUITE_DATACENTER) = VER_SUITE_DATACENTER THEN as_OSLibelle+= " Datacenter Server" ELSEIF ark_bitand(osVI.wSuiteMask,VER_SUITE_ENTERPRISE) = VER_SUITE_ENTERPRISE THEN as_OSLibelle+= " Advanced Server" ELSE as_OSLibelle+= " Server" END IF END IF ELSE ls_OSVersion = string(osVI.dwMajorVersion)+'.'+string(osVI.dwMinorVersion) as_OSLibelle+= ls_OSVersion END IF // Include service pack (IF any) as_OSLibelle+= " "+string(blob(osVI.szCSDVersion),EncodingANSI!) // Include build number. as_OSLibelle+= " (build "+string(osVI.dwBuildNumber)+")" END IF END IF RETURN ls_OSVersion
Bonjour,
Désolé pour mon ignorance si c'est le cas, je débute dans PB.
Est-ce une fonction a mettre dans une fenetre car j'ai une erreur de "data type incorrect"
Merci
Hors ligne
Salut raubry,
c'est sans doute parceque tu n'as pas crée au préalable les structures utilisées comme str_OSVERSIONINFOEX et str_SYSTEM_INFO
Sinon avec le code du tout premier post et le lien donné par erasorz ( http://msdn.microsoft.com/en-us/library … 85%29.aspx ) on arrive a un résultat plus faciement , à voir le niveau de précision dont tu as besoin pour le résultat.
Sinon voir ici pour un truc tout fait dispo en PB8 et en PB10 : http://www.topwizprogramming.com/freeco … rsion.html
Hors ligne
Je déterre ce topic suite à un truc que j'ai vu concernant le passage de W8 à 10 sans passer par la case 9 :
Les gars qui auraient codé ça devaient pas connaître GetVersionExA...
Et franchement, ça vaut presque un PEBKAC
EDIT : wahou 5000ème message
Hors ligne