Jump to content

Recommended Posts

Posted (edited)

Hi,

I'm having a hard time getting the function fully to work on other Windows than Windows:

$ret = _WinAPI_GetErrorMessage('1058')
MsgBox(0,'1', '"' & $ret & '"')
$ret = _WinAPI_GetErrorMessage('-2140993535')
MsgBox(0,'2', '"' & $ret & '"')


Func _WinAPI_GetErrorMessage($iCode, $iLanguage = 0)
    Local $aRet = DllCall('kernel32.dll', 'dword', 'FormatMessageW', 'dword', 0x1000, 'ptr', 0, 'dword', $iCode, _
            'dword', $iLanguage, 'wstr', '', 'dword', 4092, 'ptr', 0)           
    If @error Or Not $aRet[0] Then Return SetError(@error, @extended, '')
    Return StringRegExpReplace($aRet[5], '[' & @LF & ',' & @CR & ']*\Z', '')
EndFunc   ;==>_WinAPI_GetErrorMessage

The first error code (the plus code 1058) will be returned correctly on all Windows.
The second error code (the minus code -2140993535) will be returned correctly only on Windows 10.

Is there a way to make the function work on other Windows versions for minus error codes? Or is there any other way to get the error message using Autoit?

Thanks in advance.

Edited by Factfinder
Posted (edited)
34 minutes ago, JohnOne said:

first, swap these lines of code

 _ArrayDisplay($aRet)
    If @error Or Not $aRet[0] Then Return SetError(@error, @extended, '')

I removed the line. However, I had put it there because the function didn't return any extended error.

I edited the script to avoid any confusion. Thank you.

Edited by Factfinder
Posted

Easy now. In each new version of the Windows operating system there are added hundreds or thousands of new error codes and corresponding error messages. The number of error codes and error messages is always increasing.

Why do you expect that all error codes and error messages in Windows 10 also exists in Windows 7? This is a wrong assumption. But the reverse is probably true. All error codes in Windows 7 is also registered in Windows 10.

Posted
11 hours ago, LarsJ said:

Easy now. In each new version of the Windows operating system there are added hundreds or thousands of new error codes and corresponding error messages. The number of error codes and error messages is always increasing.

Why do you expect that all error codes and error messages in Windows 10 also exists in Windows 7? This is a wrong assumption. But the reverse is probably true. All error codes in Windows 7 is also registered in Windows 10.

They've always been there but developers want more and more access to the OS in order to bring a better personal experience to the user.

(or so they say)

They/We want to know what went wrong and why. And so with each new generation of windows, they give the info, usually in dll's, and soon only in that cloud.

Point is, the error codes expand because you and I, demand it.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted
20 hours ago, LarsJ said:

Easy now. In each new version of the Windows operating system there are added hundreds or thousands of new error codes and corresponding error messages. The number of error codes and error messages is always increasing.

Why do you expect that all error codes and error messages in Windows 10 also exists in Windows 7? This is a wrong assumption. But the reverse is probably true. All error codes in Windows 7 is also registered in Windows 10.

Not sure how you came to your assumtion, both the error codes are generated by Windows 7. None of them is confined to Window 10. They were there even before Windows 10 existed.

Posted (edited)

This two lines work on W7:

$ret = _WinAPI_GetErrorMessage(0x80020009) ; Exception occurred
$ret = _WinAPI_GetErrorMessage(2147614729) ; Same but decimal. Note that it is a positive value. -2147614729 returns nothing

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

I had converted my second error code to hex before applying the funtion and it did not work on Windows 7. And on Windows 10 either way works.

In fact we probably don't need to convert the negative code to hex. I have checked it and both Windows versions convert the ngative code to identical positive number.

 

 

 

 

 

Edited by Factfinder
Typo
Posted

I tried

$ret = _WinAPI_GetErrorMessage('-2140993535')

with dec and hex. And it doesn't return an error message on W7. As it returns a message for other codes I assume it is a message code that does not exist on W7.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Since the error code is generated by Windows 7, I hope the error message can be obtained from it too. Or we have to be sure before giving it up.

I have played with other values than x1000 as the flag value. 

 

 

Posted
-2140993535 (decimal) or 0x80630801 hex) stands for: PEER_E_CERT_STORE_CORRUPTED The certstore is corrupted.
https://msdn.microsoft.com/en-us/library/windows/desktop/hh404142(v=vs.85).aspx
 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...