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

NativeCall and pointers question

Thread Next
From:
ToddAndMargo via perl6-users
Date:
November 30, 2022 10:51
Subject:
NativeCall and pointers question
Message ID:
2c6c0de9-3322-95b3-8121-4af8751e27df@zoho.com
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(
   #`{
 
https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsopenservera?redirectedfrom=MSDN
       C++
       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,
-T



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About