TiC01 Posted May 4, 2010 Share Posted May 4, 2010 Hi there, I've been searching around if anyone has used the GetProductInfo() function before which is in Vista/7 Kernel32.dll, but so far I haven't found anything. While searching the web, I found a few hits, but all examples are in C++. Is there anyone out there who can tell me how to convert the following code to AutoIT ? TIA expandcollapse popuppGPI = (PGPI) GetProcAddress( GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo"); pGPI( osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType); switch( dwType ) { case PRODUCT_ULTIMATE: StringCchCat(pszOS, BUFSIZE, TEXT("Ultimate Edition" )); break; case PRODUCT_PROFESSIONAL: StringCchCat(pszOS, BUFSIZE, TEXT("Professional" )); break; case PRODUCT_HOME_PREMIUM: StringCchCat(pszOS, BUFSIZE, TEXT("Home Premium Edition" )); break; case PRODUCT_HOME_BASIC: StringCchCat(pszOS, BUFSIZE, TEXT("Home Basic Edition" )); break; case PRODUCT_ENTERPRISE: StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition" )); break; case PRODUCT_BUSINESS: StringCchCat(pszOS, BUFSIZE, TEXT("Business Edition" )); break; case PRODUCT_STARTER: StringCchCat(pszOS, BUFSIZE, TEXT("Starter Edition" )); break; case PRODUCT_CLUSTER_SERVER: StringCchCat(pszOS, BUFSIZE, TEXT("Cluster Server Edition" )); break; case PRODUCT_DATACENTER_SERVER: StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition" )); break; case PRODUCT_DATACENTER_SERVER_CORE: StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition (core installation)" )); break; case PRODUCT_ENTERPRISE_SERVER: StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition" )); break; case PRODUCT_ENTERPRISE_SERVER_CORE: StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition (core installation)" )); break; case PRODUCT_ENTERPRISE_SERVER_IA64: StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition for Itanium-based Systems" )); break; case PRODUCT_SMALLBUSINESS_SERVER: StringCchCat(pszOS, BUFSIZE, TEXT("Small Business Server" )); break; case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: StringCchCat(pszOS, BUFSIZE, TEXT("Small Business Server Premium Edition" )); break; case PRODUCT_STANDARD_SERVER: StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition" )); break; case PRODUCT_STANDARD_SERVER_CORE: StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition (core installation)" )); break; case PRODUCT_WEB_SERVER: StringCchCat(pszOS, BUFSIZE, TEXT("Web Server Edition" )); break; } } Link to comment Share on other sites More sharing options...
KaFu Posted May 4, 2010 Share Posted May 4, 2010 This nice example by NerdFencer contains the code you're searching for... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
trancexx Posted May 4, 2010 Share Posted May 4, 2010 This nice example by NerdFencer contains the code you're searching for...Where in particular? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
KaFu Posted May 4, 2010 Share Posted May 4, 2010 (edited) Try this... expandcollapse popupMsgBox(0, "_GetProductInfo()", _GetProductInfo() & @crlf & @error) Func _GetProductInfo() Local $OsArray[4] = [""] ; OSVERSIONINFOEX Structure ; http://msdn.microsoft.com/en-us/library/ms724833%28v=VS.85%29.aspx Local $OSVERSIONINFOEX = DllStructCreate("dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;char CSDVersion[128];word ServicePackMajor;word ServicePackMinor;BYTE SuiteMask;BYTE ProductType") If @error Then Return SetError(@error, 1, 0) EndIf DllStructSetData($OSVERSIONINFOEX, "OSVersionInfoSize", DllStructGetSize($OSVERSIONINFOEX)) If @error Then $OSVERSIONINFOEX = 0 Return SetError(@error, 2, 0) EndIf ; GetVersionEx Function ; http://msdn.microsoft.com/en-us/library/ms724451%28v=VS.85%29.aspx Local $retVal = DllCall("Kernel32.dll", "int", "GetVersionEx", "ptr", DllStructGetPtr($OSVERSIONINFOEX)) If @error Then $OSVERSIONINFOEX = 0 Return SetError(@error, 3, 0) EndIf $OsArray[0] = String(DllStructGetData($OSVERSIONINFOEX, "MajorVersion")) $OsArray[1] = String(DllStructGetData($OSVERSIONINFOEX, "MinorVersion")) $OsArray[2] = String(DllStructGetData($OSVERSIONINFOEX, "ServicePackMajor")) $OsArray[3] = String(DllStructGetData($OSVERSIONINFOEX, "ServicePackMinor")) $OSVERSIONINFOEX = 0 if $OsArray[0] < 6 Then Return SetError(@error, 4, 0) ; min version for GetProductInfo is Vista ; GetProductInfo Function ; http://msdn.microsoft.com/en-us/library/ms724358%28VS.85%29.aspx Local $ReturnedProductType = DllStructCreate("dword ReturnedProductType") Local $retVal = DllCall("Kernel32.dll", "int", "GetProductInfo", "dword", $OsArray[0], "dword", $OsArray[1], "dword", $OsArray[2], "dword", $OsArray[3], "dword", DllStructGetPtr($ReturnedProductType)) If @error Then Return SetError(@error, 5, 0) EndIf Return DllStructGetData($ReturnedProductType, "ReturnedProductType") EndFunc ;==>GetProductInfo Returns 1 on my machine, which is correct . Not sure, but maybe someone with not Win7 Ultimate should try. If it works, add a result switch on the values mentioned on MSDN to get an answer in clear text. Edited May 4, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
TiC01 Posted May 4, 2010 Author Share Posted May 4, 2010 This is exactly what I was looking for. Still don't quite understand how structs work, but this helps me a lot Thanx...... Link to comment Share on other sites More sharing options...
KaFu Posted May 4, 2010 Share Posted May 4, 2010 Some will beat me, but imho they're comparable to arrays.wolf9228's post on Windows Data Types <> DllCall Autoit Data Type helps finding the correct types (on MSDN switch syntax to C++).For dllcalls "In" values can be set with AutoIt variables, "Out" should be a pointer to a receiving structure. Datatypes for dllcalls can be translated from c++ to AutoIt with wolf's post. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 4, 2010 Share Posted May 4, 2010 (edited) I was doing this to get a working example with the constants included. Not an improvement on KaFu, just includes the return values from MSDN - GetProductInfo Function: expandcollapse popup#region Global Constants Global Const $PRODUCT_BUSINESS = 0x00000006 ; Business Global Const $PRODUCT_BUSINESS_N = 0x00000010 ; Business N Global Const $PRODUCT_CLUSTER_SERVER = 0x00000012 ; HPC Edition Global Const $PRODUCT_DATACENTER_SERVER = 0x00000008 ; Server Datacenter (full installation) Global Const $PRODUCT_DATACENTER_SERVER_CORE = 0x0000000C ; Server Datacenter (core installation) Global Const $PRODUCT_DATACENTER_SERVER_CORE_V = 0x00000027 ; Server Datacenter without Hyper-V (core installation) Global Const $PRODUCT_DATACENTER_SERVER_V = 0x00000025 ; Server Datacenter without Hyper-V (full installation) Global Const $PRODUCT_ENTERPRISE = 0x00000004 ; Enterprise Global Const $PRODUCT_ENTERPRISE_E = 0x00000046 ; Enterprise E Global Const $PRODUCT_ENTERPRISE_N = 0x0000001B ; Enterprise N Global Const $PRODUCT_ENTERPRISE_SERVER = 0x0000000A ; Server Enterprise (full installation) Global Const $PRODUCT_ENTERPRISE_SERVER_CORE = 0x0000000E ; Server Enterprise (core installation) Global Const $PRODUCT_ENTERPRISE_SERVER_CORE_V = 0x00000029 ; Server Enterprise without Hyper-V (core installation) Global Const $PRODUCT_ENTERPRISE_SERVER_IA64 = 0x0000000F ; Server Enterprise for Itanium-based Systems Global Const $PRODUCT_ENTERPRISE_SERVER_V = 0x00000026 ; Server Enterprise without Hyper-V (full installation) Global Const $PRODUCT_HOME_BASIC = 0x00000002 ; Home Basic Global Const $PRODUCT_HOME_BASIC_E = 0x00000043 ; Home Basic E Global Const $PRODUCT_HOME_BASIC_N = 0x00000005 ; Home Basic N Global Const $PRODUCT_HOME_PREMIUM = 0x00000003 ; Home Premium Global Const $PRODUCT_HOME_PREMIUM_E = 0x00000044 ; Home Premium E Global Const $PRODUCT_HOME_PREMIUM_N = 0x0000001A ; Home Premium N Global Const $PRODUCT_HYPERV = 0x0000002A ; Microsoft Hyper-V Server Global Const $PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT = 0x0000001E ; Windows Essential Business Server Management Server Global Const $PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING = 0x00000020 ; Windows Essential Business Server Messaging Server Global Const $PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY = 0x0000001F ; Windows Essential Business Server Security Server Global Const $PRODUCT_PROFESSIONAL = 0x00000030 ; Professional Global Const $PRODUCT_PROFESSIONAL_E = 0x00000045 ; Professional E Global Const $PRODUCT_PROFESSIONAL_N = 0x00000031 ; Professional N Global Const $PRODUCT_SERVER_FOR_SMALLBUSINESS = 0x00000018 ; Windows Server 2008 for Windows Essential Server Solutions Global Const $PRODUCT_SERVER_FOR_SMALLBUSINESS_V = 0x00000023 ; Windows Server 2008 without Hyper-V for Windows Essential Server Solutions Global Const $PRODUCT_SERVER_FOUNDATION = 0x00000021 ; Server Foundation Global Const $PRODUCT_SMALLBUSINESS_SERVER = 0x00000009 ; Windows Small Business Server Global Const $PRODUCT_SMALLBUSINESS_SERVER_PREMIUM = 0x00000019 ; Small Business Server Premium Edition Global Const $PRODUCT_STANDARD_SERVER = 0x00000007 ; Server Standard (full installation) Global Const $PRODUCT_STANDARD_SERVER_CORE = 0x0000000D ; Server Standard (core installation) Global Const $PRODUCT_STANDARD_SERVER_CORE_V = 0x00000028 ; Server Standard without Hyper-V (core installation) Global Const $PRODUCT_STANDARD_SERVER_V = 0x00000024 ; Server Standard without Hyper-V (full installation) Global Const $PRODUCT_STARTER = 0x0000000B ; Starter Global Const $PRODUCT_STARTER_E = 0x00000042 ; Starter E Global Const $PRODUCT_STARTER_N = 0x0000002F ; Starter N Global Const $PRODUCT_STORAGE_ENTERPRISE_SERVER = 0x00000017 ; Storage Server Enterprise Global Const $PRODUCT_STORAGE_EXPRESS_SERVER = 0x00000014 ; Storage Server Express Global Const $PRODUCT_STORAGE_STANDARD_SERVER = 0x00000015 ; Storage Server Standard Global Const $PRODUCT_STORAGE_WORKGROUP_SERVER = 0x00000016 ; Storage Server Workgroup Global Const $PRODUCT_UNDEFINED = 0x00000000 ; An unknown product Global Const $PRODUCT_ULTIMATE = 0x00000001 ; Ultimate Global Const $PRODUCT_ULTIMATE_E = 0x00000047 ; Ultimate E Global Const $PRODUCT_ULTIMATE_N = 0x0000001C ; Ultimate N Global Const $PRODUCT_WEB_SERVER = 0x00000011 ; Web Server (full installation) Global Const $PRODUCT_WEB_SERVER_CORE = 0x0000001D ; Web Server (core installation) Global Const $PRODUCT_UNLICENSED = 0xABCDABCD ; Product has not been activated and is no longer in the grace period #endregion Global Constants Global $iMajorVer ; Major OS version number >= 6 Global $iMinorVer ; Minor OS version number Global $iMajorSP = 0 ; Major service pack number Global $iMinorSP = 0 ; Minor service pack number Global $aRET, $iProdType, $sProdType For $iMajorVer = 5 To 8 For $iMinorVer = 0 To 4 $aRET = DllCall("kernel32.dll", "dword", "GetProductInfo", "dword", $iMajorVer, "dword", $iMinorVer, "dword", $iMajorSP, "dword", $iMinorSP, "dword*", 0) If (@error = 0) And $aRET[0] Then $iProdType = $aRET[5] Switch $iProdType Case $PRODUCT_BUSINESS $sProdType = "Business Edition" Case $PRODUCT_BUSINESS_N $sProdType = "Business Edition N" Case $PRODUCT_CLUSTER_SERVER $sProdType = "Cluster Server Edition" Case $PRODUCT_DATACENTER_SERVER $sProdType = "Datacenter Edition" Case $PRODUCT_DATACENTER_SERVER_CORE $sProdType = "Datacenter Edition (core installation)" Case $PRODUCT_DATACENTER_SERVER_V $sProdType = "Datacenter Edition without Hyper-V" Case $PRODUCT_DATACENTER_SERVER_CORE_V $sProdType = "Datacenter Edition without Hyper-V (core installation)" Case $PRODUCT_ENTERPRISE $sProdType = "Enterprise Edition" Case $PRODUCT_ENTERPRISE_SERVER $sProdType = "Enterprise Edition" Case $PRODUCT_ENTERPRISE_SERVER_V $sProdType = "Enterprise Edition without Hyper-V" Case $PRODUCT_ENTERPRISE_SERVER_CORE $sProdType = "Enterprise Edition (core installation)" Case $PRODUCT_ENTERPRISE_SERVER_CORE_V $sProdType = "Enterprise Edition without Hyper-V (core installation)" Case $PRODUCT_ENTERPRISE_SERVER_IA64 $sProdType = "Enterprise Edition for Itanium-based Systems" Case $PRODUCT_HOME_BASIC $sProdType = "Home Basic Edition" Case $PRODUCT_HOME_BASIC_E $sProdType = "Home Basic Edition E" Case $PRODUCT_HOME_BASIC_N $sProdType = "Home Basic Edition N" Case $PRODUCT_HOME_PREMIUM $sProdType = "Home Premium Edition" Case $PRODUCT_HOME_PREMIUM_E $sProdType = "Home Premium Edition E" Case $PRODUCT_HOME_PREMIUM_N $sProdType = "Home Premium Edition N" Case $PRODUCT_HYPERV $sProdType = "Microsoft Hyper-V Server" Case $PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT $sProdType = "Windows Essential Business Server Management Server" Case $PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING $sProdType = "Windows Essential Business Server Messaging Server" Case $PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY $sProdType = "Windows Essential Business Server Security Server" Case $PRODUCT_PROFESSIONAL $sProdType = "Professional" Case $PRODUCT_PROFESSIONAL_E $sProdType = "Professional E" Case $PRODUCT_PROFESSIONAL_N $sProdType = "Professional N" Case $PRODUCT_SERVER_FOR_SMALLBUSINESS $sProdType = "Windows Server 2008 for Windows Essential Server Solutions" Case $PRODUCT_SERVER_FOR_SMALLBUSINESS_V $sProdType = "Windows Server 2008 without Hyper-V for Windows Essential Server Solutions" Case $PRODUCT_SERVER_FOUNDATION $sProdType = "Server Foundation" Case $PRODUCT_SMALLBUSINESS_SERVER $sProdType = "Small Business Server" Case $PRODUCT_SMALLBUSINESS_SERVER_PREMIUM $sProdType = "Small Business Server Premium Edition" Case $PRODUCT_STANDARD_SERVER $sProdType = "Standard Edition" Case $PRODUCT_STANDARD_SERVER_CORE $sProdType = "Standard Edition (core installation)" Case $PRODUCT_STANDARD_SERVER_V $sProdType = "Standard Edition without Hyper-V" Case $PRODUCT_STANDARD_SERVER_CORE_V $sProdType = "Standard Edition without Hyper-V (core installation)" Case $PRODUCT_STARTER $sProdType = "Starter Edition" Case $PRODUCT_STARTER_E $sProdType = "Starter Edition E" Case $PRODUCT_STARTER_N $sProdType = "Starter Edition N" Case $PRODUCT_STORAGE_ENTERPRISE_SERVER $sProdType = "Storage Server Enterprise" Case $PRODUCT_STORAGE_EXPRESS_SERVER $sProdType = "Storage Server Express" Case $PRODUCT_STORAGE_STANDARD_SERVER $sProdType = "Storage Server Standard" Case $PRODUCT_STORAGE_WORKGROUP_SERVER $sProdType = "Storage Server Workgroup" Case $PRODUCT_UNDEFINED $sProdType = "UNDEFINED" Case $PRODUCT_ULTIMATE $sProdType = "Ultimate Edition" Case $PRODUCT_ULTIMATE_E $sProdType = "Ultimate Edition E" Case $PRODUCT_ULTIMATE_N $sProdType = "Ultimate Edition N" Case $PRODUCT_WEB_SERVER $sProdType = "Web Server Edition" Case $PRODUCT_WEB_SERVER_CORE $sProdType = "Web Server (core installation)" Case $PRODUCT_UNLICENSED $sProdType = "UNLICENSED" EndSwitch ConsoleWrite($iMajorVer & ":" & $iMinorVer & " - $iProdType = " & $iProdType & "; $sProdType = " & $sProdType & @LF) Else ConsoleWrite($iMajorVer & ":" & $iMinorVer & " - Fail: @error = " & @error & @LF) EndIf Next NextThis enumerates all major versions 5 thru 8, with minor versions 0 thru 4. Correctly fails for major = 5 (only supposed to work with >= 6). Correctly IDs Vista Business as $iProdType = 6. Edited May 4, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
99ojo Posted May 4, 2010 Share Posted May 4, 2010 (edited) @PsaltyDS: This looks like spade work. Thanks a lot. ;-)) Stefan @edit: Haha, thanks to KaFu as well (lazy bump.......) Edited May 4, 2010 by 99ojo Link to comment Share on other sites More sharing options...
KaFu Posted May 4, 2010 Share Posted May 4, 2010 (edited) Pong..., was just to lazy to parse the returns values . expandcollapse popup#include <array.au3> $a_GetProductInfoEx = _GetProductInfoEx() _ArrayDisplay($a_GetProductInfoEx) Func _GetProductInfoEx() #region Local Constants Local Const $PRODUCT_BUSINESS = 0x00000006 ; Business Local Const $PRODUCT_BUSINESS_N = 0x00000010 ; Business N Local Const $PRODUCT_CLUSTER_SERVER = 0x00000012 ; HPC Edition Local Const $PRODUCT_DATACENTER_SERVER = 0x00000008 ; Server Datacenter (full installation) Local Const $PRODUCT_DATACENTER_SERVER_CORE = 0x0000000C ; Server Datacenter (core installation) Local Const $PRODUCT_DATACENTER_SERVER_CORE_V = 0x00000027 ; Server Datacenter without Hyper-V (core installation) Local Const $PRODUCT_DATACENTER_SERVER_V = 0x00000025 ; Server Datacenter without Hyper-V (full installation) Local Const $PRODUCT_ENTERPRISE = 0x00000004 ; Enterprise Local Const $PRODUCT_ENTERPRISE_E = 0x00000046 ; Enterprise E Local Const $PRODUCT_ENTERPRISE_N = 0x0000001B ; Enterprise N Local Const $PRODUCT_ENTERPRISE_SERVER = 0x0000000A ; Server Enterprise (full installation) Local Const $PRODUCT_ENTERPRISE_SERVER_CORE = 0x0000000E ; Server Enterprise (core installation) Local Const $PRODUCT_ENTERPRISE_SERVER_CORE_V = 0x00000029 ; Server Enterprise without Hyper-V (core installation) Local Const $PRODUCT_ENTERPRISE_SERVER_IA64 = 0x0000000F ; Server Enterprise for Itanium-based Systems Local Const $PRODUCT_ENTERPRISE_SERVER_V = 0x00000026 ; Server Enterprise without Hyper-V (full installation) Local Const $PRODUCT_HOME_BASIC = 0x00000002 ; Home Basic Local Const $PRODUCT_HOME_BASIC_E = 0x00000043 ; Home Basic E Local Const $PRODUCT_HOME_BASIC_N = 0x00000005 ; Home Basic N Local Const $PRODUCT_HOME_PREMIUM = 0x00000003 ; Home Premium Local Const $PRODUCT_HOME_PREMIUM_E = 0x00000044 ; Home Premium E Local Const $PRODUCT_HOME_PREMIUM_N = 0x0000001A ; Home Premium N Local Const $PRODUCT_HYPERV = 0x0000002A ; Microsoft Hyper-V Server Local Const $PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT = 0x0000001E ; Windows Essential Business Server Management Server Local Const $PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING = 0x00000020 ; Windows Essential Business Server Messaging Server Local Const $PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY = 0x0000001F ; Windows Essential Business Server Security Server Local Const $PRODUCT_PROFESSIONAL = 0x00000030 ; Professional Local Const $PRODUCT_PROFESSIONAL_E = 0x00000045 ; Professional E Local Const $PRODUCT_PROFESSIONAL_N = 0x00000031 ; Professional N Local Const $PRODUCT_SERVER_FOR_SMALLBUSINESS = 0x00000018 ; Windows Server 2008 for Windows Essential Server Solutions Local Const $PRODUCT_SERVER_FOR_SMALLBUSINESS_V = 0x00000023 ; Windows Server 2008 without Hyper-V for Windows Essential Server Solutions Local Const $PRODUCT_SERVER_FOUNDATION = 0x00000021 ; Server Foundation Local Const $PRODUCT_SMALLBUSINESS_SERVER = 0x00000009 ; Windows Small Business Server Local Const $PRODUCT_SMALLBUSINESS_SERVER_PREMIUM = 0x00000019 ; Small Business Server Premium Edition Local Const $PRODUCT_STANDARD_SERVER = 0x00000007 ; Server Standard (full installation) Local Const $PRODUCT_STANDARD_SERVER_CORE = 0x0000000D ; Server Standard (core installation) Local Const $PRODUCT_STANDARD_SERVER_CORE_V = 0x00000028 ; Server Standard without Hyper-V (core installation) Local Const $PRODUCT_STANDARD_SERVER_V = 0x00000024 ; Server Standard without Hyper-V (full installation) Local Const $PRODUCT_STARTER = 0x0000000B ; Starter Local Const $PRODUCT_STARTER_E = 0x00000042 ; Starter E Local Const $PRODUCT_STARTER_N = 0x0000002F ; Starter N Local Const $PRODUCT_STORAGE_ENTERPRISE_SERVER = 0x00000017 ; Storage Server Enterprise Local Const $PRODUCT_STORAGE_EXPRESS_SERVER = 0x00000014 ; Storage Server Express Local Const $PRODUCT_STORAGE_STANDARD_SERVER = 0x00000015 ; Storage Server Standard Local Const $PRODUCT_STORAGE_WORKGROUP_SERVER = 0x00000016 ; Storage Server Workgroup Local Const $PRODUCT_UNDEFINED = 0x00000000 ; An unknown product Local Const $PRODUCT_ULTIMATE = 0x00000001 ; Ultimate Local Const $PRODUCT_ULTIMATE_E = 0x00000047 ; Ultimate E Local Const $PRODUCT_ULTIMATE_N = 0x0000001C ; Ultimate N Local Const $PRODUCT_WEB_SERVER = 0x00000011 ; Web Server (full installation) Local Const $PRODUCT_WEB_SERVER_CORE = 0x0000001D ; Web Server (core installation) Local Const $PRODUCT_UNLICENSED = 0xABCDABCD ; Product has not been activated and is no longer in the grace period #endregion Local Constants Local $OsArray[10][2] = [["OSMajorVersion", ""],["OSMinorVersion", ""],["ServicePackMajor", ""],["ServicePackMinor", ""],["ReturnedProductType", ""],["ReturnedProductType_Text", ""],["PlatformId", ""],["CSDVersion", ""],["SuiteMask", ""],[" ProductType", ""]] ; OSVERSIONINFOEX Structure ; http://msdn.microsoft.com/en-us/library/ms724833%28v=VS.85%29.aspx Local $OSVERSIONINFOEX = DllStructCreate("dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;char CSDVersion[128];word ServicePackMajor;word ServicePackMinor;BYTE SuiteMask;BYTE ProductType") If @error Then Return SetError(@error, 1, 0) EndIf DllStructSetData($OSVERSIONINFOEX, "OSVersionInfoSize", DllStructGetSize($OSVERSIONINFOEX)) If @error Then $OSVERSIONINFOEX = 0 Return SetError(@error, 2, 0) EndIf ; GetVersionEx Function ; http://msdn.microsoft.com/en-us/library/ms724451%28v=VS.85%29.aspx Local $retVal = DllCall("Kernel32.dll", "int", "GetVersionEx", "ptr", DllStructGetPtr($OSVERSIONINFOEX)) If @error Then $OSVERSIONINFOEX = 0 Return SetError(@error, 3, 0) EndIf $OsArray[0][1] = String(DllStructGetData($OSVERSIONINFOEX, "MajorVersion")) $OsArray[1][1] = String(DllStructGetData($OSVERSIONINFOEX, "MinorVersion")) $OsArray[2][1] = String(DllStructGetData($OSVERSIONINFOEX, "ServicePackMajor")) $OsArray[3][1] = String(DllStructGetData($OSVERSIONINFOEX, "ServicePackMinor")) $OsArray[6][1] = String(DllStructGetData($OSVERSIONINFOEX, "PlatformId")) $OsArray[7][1] = String(DllStructGetData($OSVERSIONINFOEX, "CSDVersion")) $OsArray[8][1] = String(DllStructGetData($OSVERSIONINFOEX, "SuiteMask")) $OsArray[9][1] = String(DllStructGetData($OSVERSIONINFOEX, "ProductType")) $OSVERSIONINFOEX = 0 If $OsArray[0][1] < 6 Then $OsArray[4][1] = 0 $OsArray[5][1] = "Minimum OS Version to retreive ProductType is Vista" Return SetError(@error, 4, $OsArray) ; min version for GetProductInfo is Vista EndIf ; GetProductInfo Function ; http://msdn.microsoft.com/en-us/library/ms724358%28VS.85%29.aspx Local $ReturnedProductType = DllStructCreate("dword ReturnedProductType") Local $retVal = DllCall("Kernel32.dll", "int", "GetProductInfo", "dword", $OsArray[0][1], "dword", $OsArray[1][1], "dword", $OsArray[2][1], "dword", $OsArray[3][1], "dword", DllStructGetPtr($ReturnedProductType)) If @error Then Return SetError(@error, 5, 0) EndIf $OsArray[4][1] = DllStructGetData($ReturnedProductType, "ReturnedProductType") Switch $OsArray[4][1] Case $PRODUCT_BUSINESS $OsArray[5][1] = "Business Edition" Case $PRODUCT_BUSINESS_N $OsArray[5][1] = "Business Edition N" Case $PRODUCT_CLUSTER_SERVER $OsArray[5][1] = "Cluster Server Edition" Case $PRODUCT_DATACENTER_SERVER $OsArray[5][1] = "Datacenter Edition" Case $PRODUCT_DATACENTER_SERVER_CORE $OsArray[5][1] = "Datacenter Edition (core installation)" Case $PRODUCT_DATACENTER_SERVER_V $OsArray[5][1] = "Datacenter Edition without Hyper-V" Case $PRODUCT_DATACENTER_SERVER_CORE_V $OsArray[5][1] = "Datacenter Edition without Hyper-V (core installation)" Case $PRODUCT_ENTERPRISE $OsArray[5][1] = "Enterprise Edition" Case $PRODUCT_ENTERPRISE_SERVER $OsArray[5][1] = "Enterprise Edition" Case $PRODUCT_ENTERPRISE_SERVER_V $OsArray[5][1] = "Enterprise Edition without Hyper-V" Case $PRODUCT_ENTERPRISE_SERVER_CORE $OsArray[5][1] = "Enterprise Edition (core installation)" Case $PRODUCT_ENTERPRISE_SERVER_CORE_V $OsArray[5][1] = "Enterprise Edition without Hyper-V (core installation)" Case $PRODUCT_ENTERPRISE_SERVER_IA64 $OsArray[5][1] = "Enterprise Edition for Itanium-based Systems" Case $PRODUCT_HOME_BASIC $OsArray[5][1] = "Home Basic Edition" Case $PRODUCT_HOME_BASIC_E $OsArray[5][1] = "Home Basic Edition E" Case $PRODUCT_HOME_BASIC_N $OsArray[5][1] = "Home Basic Edition N" Case $PRODUCT_HOME_PREMIUM $OsArray[5][1] = "Home Premium Edition" Case $PRODUCT_HOME_PREMIUM_E $OsArray[5][1] = "Home Premium Edition E" Case $PRODUCT_HOME_PREMIUM_N $OsArray[5][1] = "Home Premium Edition N" Case $PRODUCT_HYPERV $OsArray[5][1] = "Microsoft Hyper-V Server" Case $PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT $OsArray[5][1] = "Windows Essential Business Server Management Server" Case $PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING $OsArray[5][1] = "Windows Essential Business Server Messaging Server" Case $PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY $OsArray[5][1] = "Windows Essential Business Server Security Server" Case $PRODUCT_PROFESSIONAL $OsArray[5][1] = "Professional" Case $PRODUCT_PROFESSIONAL_E $OsArray[5][1] = "Professional E" Case $PRODUCT_PROFESSIONAL_N $OsArray[5][1] = "Professional N" Case $PRODUCT_SERVER_FOR_SMALLBUSINESS $OsArray[5][1] = "Windows Server 2008 for Windows Essential Server Solutions" Case $PRODUCT_SERVER_FOR_SMALLBUSINESS_V $OsArray[5][1] = "Windows Server 2008 without Hyper-V for Windows Essential Server Solutions" Case $PRODUCT_SERVER_FOUNDATION $OsArray[5][1] = "Server Foundation" Case $PRODUCT_SMALLBUSINESS_SERVER $OsArray[5][1] = "Small Business Server" Case $PRODUCT_SMALLBUSINESS_SERVER_PREMIUM $OsArray[5][1] = "Small Business Server Premium Edition" Case $PRODUCT_STANDARD_SERVER $OsArray[5][1] = "Standard Edition" Case $PRODUCT_STANDARD_SERVER_CORE $OsArray[5][1] = "Standard Edition (core installation)" Case $PRODUCT_STANDARD_SERVER_V $OsArray[5][1] = "Standard Edition without Hyper-V" Case $PRODUCT_STANDARD_SERVER_CORE_V $OsArray[5][1] = "Standard Edition without Hyper-V (core installation)" Case $PRODUCT_STARTER $OsArray[5][1] = "Starter Edition" Case $PRODUCT_STARTER_E $OsArray[5][1] = "Starter Edition E" Case $PRODUCT_STARTER_N $OsArray[5][1] = "Starter Edition N" Case $PRODUCT_STORAGE_ENTERPRISE_SERVER $OsArray[5][1] = "Storage Server Enterprise" Case $PRODUCT_STORAGE_EXPRESS_SERVER $OsArray[5][1] = "Storage Server Express" Case $PRODUCT_STORAGE_STANDARD_SERVER $OsArray[5][1] = "Storage Server Standard" Case $PRODUCT_STORAGE_WORKGROUP_SERVER $OsArray[5][1] = "Storage Server Workgroup" Case $PRODUCT_UNDEFINED $OsArray[5][1] = "UNDEFINED" Case $PRODUCT_ULTIMATE $OsArray[5][1] = "Ultimate Edition" Case $PRODUCT_ULTIMATE_E $OsArray[5][1] = "Ultimate Edition E" Case $PRODUCT_ULTIMATE_N $OsArray[5][1] = "Ultimate Edition N" Case $PRODUCT_WEB_SERVER $OsArray[5][1] = "Web Server Edition" Case $PRODUCT_WEB_SERVER_CORE $OsArray[5][1] = "Web Server (core installation)" Case $PRODUCT_UNLICENSED $OsArray[5][1] = "UNLICENSED" EndSwitch Return $OsArray EndFunc ;==>_GetProductInfoEx Edited May 4, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
TiC01 Posted May 4, 2010 Author Share Posted May 4, 2010 Thanks all you guys. I've been working here also, but you are a whole lot faster than me Link to comment Share on other sites More sharing options...
wraithdu Posted May 4, 2010 Share Posted May 4, 2010 $OsArray[0][1] = String(DllStructGetData($OSVERSIONINFOEX, "MajorVersion")) ... No reason to cast to String here. They are all dword values in the OsVersionInfoEx structure, and the GetProductInfo function is expecting dwords. Link to comment Share on other sites More sharing options...
KaFu Posted May 4, 2010 Share Posted May 4, 2010 No reason to cast to String here. They are all dword values in the OsVersionInfoEx structure, and the GetProductInfo function is expecting dwords.Of course you're right, copy&pasted the GetVersionEx part ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now