Archive: calling NetGetJoinInformation with System::Call - parameter format?


calling NetGetJoinInformation with System::Call - parameter format?
I need to use the Win32 API "NetGetJoinInformation()", and am having problems figuring out the right syntax when using "System::Call".

The API format is as follows:

NET_API_STATUS NetGetJoinInformation(
_In_ LPCWSTR lpServer,
_Out_ LPWSTR *lpNameBuffer,
_Out_ PNETSETUP_JOIN_STATUS BufferType
);

typedef enum _NETSETUP_JOIN_STATUS {
NetSetupUnknownStatus = 0,
NetSetupUnjoined,
NetSetupWorkgroupName,
NetSetupDomainName
} NETSETUP_JOIN_STATUS, *PNETSETUP_JOIN_STATUS;


  1. NET_API_STATUS is a DWORD
  2. The first parameter can be a NULL or ""
  3. The second parameter is "A Pointer to the buffer that receives the NetBIOS name of the domain or workgroup to which the computer is joined. Is allocated by the system and must be freed using the NetApiBufferFree function."

So I'm using the following to call the API:

System::Call 'Netapi32::NetGetJoinInformation(w "", *w.r0,*i.r1)i.r2'


My project runs on Win7 but crashes on XP when I call that API (it works in an VC++ app, so I know it isn't an unsupported API in XP). So I'm assuming that my parameter format for System::Call isn't 100% correct and this is causing the crash.

Any suggestions?

System::Call 'Netapi32::NetGetJoinInformation(w "", *i.r0,*i.r1)i.r2'
System::Call '*$0(&w1024.r3)' ; $0 is the address of some memory where the string is stored
...NetApiBufferFree(ir0)
or something like that (Did not test this code). * can usually not be combined with t/m/w.


Excellent. That fixed it! Thanks!