develooper Front page | perl.perl6.users | Postings from November 2022

NativeCall and pointers question

Thread Next
ToddAndMargo via perl6-users
November 30, 2022 10:51
NativeCall and pointers question
Message ID:
Hi All,

In the following:

use NativeCall;
constant BYTE     := uint8;
constant LPDWORD  := uint64;        # long pointer to a DWORD
constant LPSTR    = CArray[BYTE];   # long pointer to a string
constant DWORD    := uint32;
constant HANDLE   = Pointer[void];

sub WTSOpenServerA(
       HANDLE WTSOpenServerA(
       [in] LPSTR pServerName

    LPSTR $pServerName

    is native("Wtsapi32.dll")
    is symbol("WTSOpenServerA")
    returns DWORD
    { * };

NativeCall is resolving the pointers automatically
for me.  It is taking $pServerName, which is a
Long Pointer to String (LPSTR) and creating the
pointer for me.  This is appreciated.

It also returns and resolves the value of “HANDLE”
which is a C Pointer DWORD..

Question 1:  how do I tell NativeCall I actually
want the C Pointer of HANDLE  back and not what
it resolves to?

Question 2: how do I give NativeCall a pointer
value and tell Native call I do not want it
resolved into another pointer?

Many thanks,

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About