Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointer to Pointer #106

Open
OsmarSilva opened this issue Aug 2, 2017 · 3 comments
Open

Pointer to Pointer #106

OsmarSilva opened this issue Aug 2, 2017 · 3 comments

Comments

@OsmarSilva
Copy link

@TooTallNate I have a problem with pointer to pointer of struct.
well, I have the code in c/c++

typedef struct _wfs_ptr_status
{
WORD fwDevice;
WORD fwMedia;
WORD fwPaper[WFS_PTR_SUPPLYSIZE];
WORD fwToner;
WORD fwInk;
WORD fwLamp;
LPWFSPTRRETRACTBINS * lppRetractBins;
USHORT usMediaOnStacker;
LPSTR lpszExtra;
} WFSPTRSTATUS, * LPWFSPTRSTATUS;

typedef struct _wfs_result
{
 REQUESTID RequestID;
 HSERVICE hService;
 SYSTEMTIME tsTimestamp;
 HRESULT hResult;
 union {
 DWORD dwCommandCode;
 DWORD dwEventID;
 } u;
 LPVOID lpBuffer;
} WFSRESULT, * LPWFSRESULT;

WFSRESULT *pResult = 0;
WFSGetInfo (&pResult);

LPWFSPTRSTATUS lpStatus = (LPWFSPTRSTATUS)pResult->lpBuffer;

in node-ffi, I've the code:

var WFSRESULT = Struct({
 'RequestID': 'ulong',
 'hService': 'ushort',
 'tsTimestamp': SYSTEMTIME,
 'hResult': 'long',
 'u': union,
 'lpBuffer': 'pointer'
})

var LPWFSRESULT = ref.refType(WFSRESULT)

...
...
...
var pResult = ref.alloc(LPWFSRESULT,0)
lib.WFSGetInfo (pResult);
var result = pResult.deref().deref()

//c++ code - LPWFSPTRSTATUS lpStatus = (LPWFSPTRSTATUS)pResult->lpBuffer;
result.lpBuffer.type = ref.refType(LPWFSPTRSTATUS)  //is this working?

but I don't know this code is correct. How to access the fields of the WFSPTRSTATUS struct as c++ code?

@TooTallNate
Copy link
Owner

Did you mean to open this over at https://github.com/node-ffi/node-ffi?

@OsmarSilva
Copy link
Author

Yes. @TooTallNate my problem is how to convert the code below to node-ffi. And how to access the fields of LPWFSPTRSTATUS struct.

//c++ code - LPWFSPTRSTATUS lpStatus = (LPWFSPTRSTATUS)pResult->lpBuffer;

@OsmarSilva
Copy link
Author

Sorry. Now that I saw that I opened the issue in the wrong place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants