Sign in to follow this  
Followers 0
asdf8

Error Au3Check 3.3.10.0

4 posts in this topic

Au3Check gives not correct warning in the following case:

#AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

Func _GetLastErrorFormatMsg($iLastError)
    $iLastError = BitAND($iLastError, 0x0000FFFF)
    Local $iPtr = DllStructCreate('char[4096]')
    If @error Then Return 'Error code : ' & $iLastError
    Local $aDllCall = DllCall('kernel32.dll', 'int', 'FormatMessage', _
            'int', 0x00001000, _ ;Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000
            'ptr', 0, _
            'int', $iLastError, _
            'int', 0, _
            'ptr', DllStructGetPtr($iPtr), _
            'int', 4096, _
            'ptr', 0)
    Local $sErrorMsg = DllStructGetData($iPtr, 1)
    $sErrorMsg = StringReplace($sErrorMsg, @CR, '')
    $sErrorMsg = StringReplace($sErrorMsg, @LF, '')
    $sErrorMsg = 'Error code : ' & $iLastError & ' (' & $sErrorMsg & ')'
    Return $sErrorMsg
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Add this two line to WinAPI.au3

Global Const $__WINAPICONSTANT_FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x100
Global Const $__WINAPICONSTANT_FORMAT_MESSAGE_FROM_SYSTEM = 0x1000
 
Func _WinAPI_GetErrorMessageByCode($code)
Local $tBufferPtr = DllStructCreate("ptr")
Local $pBufferPtr = DllStructGetPtr($tBufferPtr)


Local $nCount = _WinAPI_FormatMessage(BitOR($__WINAPICONSTANT_FORMAT_MESSAGE_ALLOCATE_BUFFER, $__WINAPICONSTANT_FORMAT_MESSAGE_FROM_SYSTEM), _
0, $code, 0, $pBufferPtr, 0, 0)
If @error Then Return SetError(@error, 0, "")


Local $sText = ""
Local $pBuffer = DllStructGetData($tBufferPtr, 1)
If $pBuffer Then
If $nCount > 0 Then
Local $tBuffer = DllStructCreate("wchar[" &($nCount+1) & "]", $pBuffer)
$sText = DllStructGetData($tBuffer, 1)
EndIf
_WinAPI_LocalFree($pBuffer)
EndIf


Return $sText
EndFunc   ;==>_WinAPI_GetErrorMessageByCode
Edited by madzero

Share this post


Link to post
Share on other sites

madzero

The gist of my post is not in the functionality of the code, but in that that is syntactically (yes and functionally) correct code is irrelevant warnings by the syntax check.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

madzero,

Please don't suggest to users to touch the WinAPI UDFs, this can land you (or others) in serious trouble when you update to the next version of AutoIt.

asdf8,

The error of $aDllCall not being using is correct, why declare a variable if you're not going to use it? Anyway, look at using #forceref to suppress these sort of warnings.

Conclusion: No Bug.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

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  
Followers 0