asdf8 Posted December 25, 2013 Posted December 25, 2013 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
madzero Posted December 25, 2013 Posted December 25, 2013 (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 December 25, 2013 by madzero
asdf8 Posted December 25, 2013 Author Posted December 25, 2013 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.
guinness Posted December 25, 2013 Posted December 25, 2013 (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 December 25, 2013 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
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