On 12/27/19 10:31 PM, T wrote:
> On 2019-12-27 07:05, Manfred wrote:
>> Moreover, this question is about a Windows API, which is in C, not C++.
>> And how to call it from Perl. Long live polyglots!
>
> Hi Mansfred,
>
> If you look at
>
>
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw
>
>
> You will find a definition for C++, not C, unless
> this is a terrible misprint of M$'s part, which I
> would not put past them.
As Paavo replied, C++ in their docs is opposed to VB and C#, not C
(being Visual C++, Visual Basic and C# probably their most popular
development products).
Technically, for the purpose of that API, C is a subset of C++, so it is
not incorrect.
A further confirmation that it is a C API is that windows headers
declare its functions as 'extern "C"' when compiled in C++ code, so that
C++ can transparently link to the API.
One relevant difference (between a C and C++ API) for interfacing with
other languages is that in order to allow for function overloading, C++
would require its exported symbol names to be mangled, while C does not.
>
> C++
> LSTATUS RegOpenKeyExW(
> HKEY hKey,
> LPCWSTR lpSubKey,
> DWORD ulOptions,
> REGSAM samDesired,
> PHKEY phkResult
> );
(A side note about the 'W' suffix (or 'A'): When applicable, Windows API
functions come in two variants for ASCII and wide char (Unicode)
strings; the companion function of the above is RegOpenKeyExA that
handles ASCII strings. The documentation often refers to both
collectively as RegOpenKeyEx, while the DLL exported function names are
RegOpenKeyExA and RegOpenKeyExW)
>
> As far as calling it from Raku/Perl6, that is a migraine I
> would not wish on anyone. Believe it or not, this group is
> about 5 times more helpful with me configuring the
> proper data structures for Raku's NativeCall. Didn't
> think you guys were that smart, did you!
I am not an expert in Perl, but I would expect its documentation to give
detailed information on how its runtime calls shared library functions.
In addition, as Paavo said, some knowledge of C is also required.
>
> -T
>