HI!
I am trying to call a function, that takes a buffer as parameter. This
buffer could be anything, but is today a specific struct.
The function can be called with buffer length 0 to determine the needed
buffer size. Then you call it again with the correct allocated buffer.
There are plenty of Win32 function that work like this.
But how do I later convert the buffer to the Structure? I only know a
way to convert a Pointer to a Structure (with useMemory()).
This is the function:
BOOL WINAPI QueryServiceStatusEx(
__in SC_HANDLE hService,
__in SC_STATUS_TYPE InfoLevel,
__out_opt LPBYTE lpBuffer,
__in DWORD cbBufSize,
__out LPDWORD pcbBytesNeeded
);
When I declare lpBuffer as type of the Structure and call the function
first with cbBufSize = 0 and then with cbBufSize = pcbBytesNeeded, it
works. But that's only for the current implementation.
For this, I have declared the function like this:
public boolean QueryServiceStatusEx(Pointer hService, int InfoLevel,
SERVICE_STATUS_PROCESS lpBuffer, int cbBufSize, IntByReference
pcbBytesNeeded);
But I'd like it more like this, to make it more future proof:
public boolean QueryServiceStatusEx(Pointer hService, int InfoLevel,
byte[] lpBuffer, int cbBufSize, IntByReference pcbBytesNeeded);
But then how to convert lpBuffer to the Structure?
Thanks!
Thomas