Template: get function name

novice3 sorryno at em.ail
Mon Aug 17 09:45:55 UTC 2020


> On Monday, 17 August 2020 at 08:55:49 UTC, Simen Kjærås wrote:
>> Take the function as an alias parameter and wrap the entire 
>> call:

Simen, for some reasons, your code dont respect api arg with 
"out" attribute.

For example, i have
```
extern (Windows)
DhcpEnumServers(
     in      DWORD                    Flags,         // must be 
zero
     in      LPVOID                   IdInfo,        // must be 
NULL
     out     LPDHCP_SERVER_INFO_ARRAY Servers,       // output 
servers list
     in      LPVOID                   CallbackFn,    // must be 
NULL
     in      LPVOID                   CallbackData   // must be 
NULL
);
```

and then i use it:
```
LPDHCP_SERVER_INFO_ARRAY servers;
denforce!DhcpEnumServers(0, null, servers, null, null);
```

access violation occur.
In disassembler we can see that servers parameter passed by value 
(initial 0 instead of address).
In my earler code it wass passed properly, by ref.

May be this not matter of your code,
and i can bypass it by change extern declaration to

   LPDHCP_SERVER_INFO_ARRAY *Servers,

but it will be interest to know the reasons...

Any way, tnaks you for your code, i will use it.


More information about the Digitalmars-d-learn mailing list