No object was created and you are modifying struct members by a pointer that does not point to anything. This is undefined behavior.
The error is in:
LPWFSPTRRETRACTBINS RetractBins;
RetractBins->wRetractBin = WFS_PTR_RETRACTBININSERTED;
RetractBins->usRetractCount = 0;
Here RetractBins
is a _wfs_ptr_retract_bins
pointer that points to no objects.
The right thing is to first create a WFSPTRRETRACTBINS
object and then pass its memory address to the RetractBins
pointer.
The correct code would be: (without using windows.h )
#include <iostream>
#define WFS_PTR_RETRACTBININSERTED 5
typedef unsigned short USHORT;
typedef unsigned short WORD;
typedef struct _wfs_ptr_retract_bins
{
WORD wRetractBin;
USHORT usRetractCount;
} WFSPTRRETRACTBINS, *LPWFSPTRRETRACTBINS;
typedef struct _wfs_ptr_status
{
LPWFSPTRRETRACTBINS *lppRetractBins;
} WFSPTRSTATUS, *LPWFSPTRSTATUS;
int main()
{
WFSPTRSTATUS PtrStatus;
WFSPTRRETRACTBINS objRetractBins; //primeiro criar um objeto válido na memoria
LPWFSPTRRETRACTBINS RetractBins;
RetractBins = &objRetractBins; // agora sim, o ponteiro RetractBins aponta para um objeto
RetractBins->wRetractBin = WFS_PTR_RETRACTBININSERTED;
RetractBins->usRetractCount = 15;
PtrStatus.lppRetractBins = &RetractBins;//AQUI QUERO PASSAR
std::cout << (*PtrStatus.lppRetractBins)->wRetractBin << std::endl; //lppRetractBins é um ponteiro para ponteiro, é necessário dereferencialo.
}