Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I need a list of the return codes

16 views
Skip to first unread message

T

unread,
Dec 27, 2019, 1:48:18 AM12/27/19
to
Hi All,

I am trying to code the following in Raku's (Perl 6's)
NativeCall:

https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw

C++
LSTATUS RegOpenKeyExW(
HKEY hKey,
LPCWSTR lpSubKey,
DWORD ulOptions,
REGSAM samDesired,
PHKEY phkResult
);
Return value
If the function succeeds, the return value is ERROR_SUCCESS.

I am getting back a 2 from RegOpenKeyExW and a 6
from RegCloseKey. (0 means success.)

So, I am feeding RegOpenKeyExW something it does not like.

Is there a list somewhere that will tell me what the
return codes mean?

Many thanks,
-T

Bonita Montero

unread,
Dec 27, 2019, 2:10:06 AM12/27/19
to
> Hi All,
> I am trying to code the following in Raku's (Perl 6's)
> NativeCall:

> https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw

"If the function fails, the return value is a nonzero error code defined
in Winerror.h."
^^^^^^^^^^

Öö Tiib

unread,
Dec 27, 2019, 2:13:10 AM12/27/19
to
The online docs you cite say that list is in Winerror.h and you can
also FormatMessage to get short description. What holds you back?

T

unread,
Dec 27, 2019, 2:49:25 AM12/27/19
to
On 2019-12-26 23:09, Bonita Montero wrote:
>> Hi All,
>> I am trying to code the following in Raku's (Perl 6's)
>> NativeCall:
>
>> https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw
>
>
> "If the function fails, the return value is a nonzero error code defined
> in Winerror.h."

Hi Bonita,

Found it. Thank you!

System Error Codes (0-499)
https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-

ERROR_FILE_NOT_FOUND

2 (0x2)

The system cannot find the file specified.


ERROR_INVALID_HANDLE

6 (0x6)

The handle is invalid.



-T



T

unread,
Dec 27, 2019, 2:49:46 AM12/27/19
to

Alf P. Steinbach

unread,
Dec 27, 2019, 7:55:15 AM12/27/19
to
On 27.12.2019 08:09, Bonita Montero wrote:
>> Hi All,
>> I am trying to code the following in Raku's (Perl 6's)
>> NativeCall:
>
>> https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw
>
>
> "If the function fails, the return value is a nonzero error code defined
> in Winerror.h."
>    ^^^^^^^^^^

In addition to the descriptions in the <winerror.h> header, the
`FormatMessage` API function produces a textual description from a
message DLL. The default message DLL has the descriptions in
`<winerror.h>` plus some more (the descriptions in the header are valid
input to the mc message compiler in order to produce a message DLL).
Some other message DLLs reside in the Windows system folder.

`FormatMessage` is the underlying engine of Microsoft's `errlook`
utility. Unfortunately that's a little GUI program, so it's less than
generally useful. It's been that way since the late 1990s.

In the command line you can use the more limited facilities of
Powershell to get a description, e.g. using a batch file like this:


--------------------------------------------------------------------
echo off

if "%1"=="" (
echo Usage: %0 NUMBER 1>&2
exit /b 1
)

if "%1"=="1" (
echo Something failed ^(could also be "Incorrect function" or
"S_FALSE"^).
) else (
powershell -command "[ComponentModel.Win32Exception] %1" 2>nul ^
|| echo "%1" must be a number. 1>&2
)
--------------------------------------------------------------------


The reason for the special treatment of code 1 is the unreasonable
convention of all extant Windows C and C++ implementations of defining
EXIT_FAILURE as code 1, when code 1 already has two meanings, widening
that ambiguity to /three/ possible meanings.

It's IMO just so needlessly braindead.

Anyway, hope this helps.


- Alf
0 new messages