Skip to content

Pointer to Pointer #106

@OsmarSilva

Description

@OsmarSilva

@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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions