Jump to content
Sign in to follow this  

UINT16 and UINT32 conversion

Recommended Posts


Morning! I'm trying to convert a UINT16 (and possibly UINT32) into usable information, specifically for the Win32_PnPEntity class "Availability" property. I can't for the life of me figure out how to do this properly; keeps displaying 0 instead of something like 0x1. Perhaps I'm just "doing it wrong". Information regarding this WMI class is shown here http://msdn.microsoft.com/en-us/library/aa394353%28v=vs.85%29.aspx . And I was able to find a VB way of handling this http://msdn.microsoft.com/en-us/library/8444cfyw.aspx but again I'm unsure on how to relate this to AutoIT. There's also this codeguru WMI enumeration script that talks about it http://www.codeproject.com/KB/scripting/wmiadmin.aspx .

Any help would be much appreciated and you'll have my accolades :)

Edited by kickarse

Share this post

Link to post
Share on other sites

There is nothing special about a UINT type, it's just a number. The problem is that the Availability property doesn't return a value at all (nul string) for many devices, depending on the device firmware, driver, etc.

Global Const $wbemFlagReturnImmediately = 0x10
Global Const $wbemFlagForwardOnly = 0x20
Global $wbemFlags = $wbemFlagReturnImmediately + $wbemFlagForwardOnly
Global $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
Global $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity", "WQL", $wbemFlags)
Global $sMsg = ""
For $objItem In $colItems
    $vAvailability = $objItem.Availability
    $sMsg &= ("Availability: " & $vAvailability & "; " & VarGetType($vAvailability) & @LF)
    $sMsg &= ("ClassGuid: " & $objItem.ClassGuid & @LF)
    $sMsg &= ("CreationClassName: " & $objItem.CreationClassName & @LF)
    $sMsg &= ("Description: " & $objItem.Description & @LF)
    $sMsg &= ("DeviceID: " & $objItem.DeviceID & @LF)
    $sMsg &= ("Manufacturer: " & $objItem.Manufacturer & @LF)
    $sMsg &= ("Name: " & $objItem.Name & @LF)
    $sMsg &= ("PNPDeviceID: " & $objItem.PNPDeviceID & @LF)
    $sMsg &= ("SystemName: " & $objItem.SystemName & @LF)
    $sMsg &= ("----------------------------------------" & @LF)
MsgBox(64, "Results", $sMsg)


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

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.