Modify

#3971 closed Bug (No Bug)

Integer not handled properly when calling object method

Reported by: BiatuAutMiahn@… Owned by:
Milestone: Component: AutoIt
Version: 3.3.14.0 Severity: None
Keywords: Cc:

Description (last modified by mLipok)

#include <WinAPIError.au3>
Global $oErrorHandler = ObjEvent("AutoIt.Error", "COMErrorHandler")

Func COMErrorHandler()
    ConsoleWrite(_WinAPI_GetLastErrorMessage()&@CRLF)
    Local $errorDescription = $oErrorHandler.description
    ConsoleWrite("COM Error occurred: " & @error & @CRLF & "Description: " & $errorDescription)
EndFunc

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\.\root\Microsoft\Windows\Storage")
$colItems = $objWMIService.ExecQuery('SELECT * FROM MSFT_Disk', "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

Local $iMBytes=1024*1024
Local $iGBytes=1024*$iMBytes
Local $iSizeEfi=512*$iMBytes
Local $iSizeMsr=128*$iMBytes
Local $iSizeRec=$iGBytes


If IsObj($colItems) then
   For $objItem In $colItems
      If $objItem.Path<>"\\?\usbstor#disk&ven_iodd&prod__vhdd_gadget_1&rev_#230603390000000092&3#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}" Then ContinueLoop
      $objItem.Clear(1,1)&@CRLF)
      $objItem.Initialize(2)&@CRLF)
      $objItem.Refresh()&@CRLF)
      $objItem.CreatePartition($iSizeEfi); works
      $objItem.CreatePartition($iSizeMsr); works
      $objItem.CreatePartition(2147483647)&@CRLF); Works
      $objItem.CreatePartition(2147483648)&@CRLF); Fails
      $objItem.CreatePartition(16*$iGBytes)&@CRLF); Fails
      ExitLoop
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "MSFT_Disk" )
Endif

Func ConvertSize($iSize, $iPrecision = 2)
    Local Const $aUnits = StringSplit("|K|M|G|T|P|E|Z|Y",'|',2)
    Local $iUnit = Int(Log($iSize)/Log(1024))
    Return String(Round($iSize / 1024 ^ $iUnit, $iPrecision)) & ' ' & $aUnits[$iUnit] & "B"
EndFunc

Calling CreatePartition with any integer greater than 2147483647 fails with Type Mismatch.

Attachments (0)

Change History (3)

comment:1 Changed 16 months ago by BiatuAutMiahn@…

Decided to port to C++, but in the process I ran into an issue where The Size property of MSFT_Disk was being return as a string instead of UInt32 as states in MSFN, eventually I ran into this https://stackoverflow.com/a/20431978, where they mention windows returns a string on purpose, then I had the thought...what if I pass the partition size as a string? Well that did it.

comment:2 Changed 16 months ago by mLipok

  • Description modified (diff)

comment:3 Changed 16 months ago by Jpm

  • Resolution set to No Bug
  • Status changed from new to closed

I close the ticket as no bug

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.