E
Elmar Jacobs
Hi folk,
I try to marshal following structure from a c++ dll to a c# smart device
application.
My problem is the BYTE stream. It woud not fill with data from the marshal
function PtrToStructure(). How can I fill the BYTE stream?
Thanks a lot,
elmar
c++ interface
[cpp]
typedef struct pHeaderData{
int spectrumNumber;
int spectrumType;
int spectrumLength;
BYTE startTime[8]; //bcd YYMMDDWWhhmmssHH
BYTE stopTime[8]; //bcd YYMMDDWWhhmmssHH
int realTime;
int liveTime;
int dwellTime;
}headerData;
c# part
public struct pSpectrumHeaderStruct
{
public uint spectrumNumber;
public uint spectrumType;
public uint spectrumLength;
public byte [] startTime;
public byte [] stopTime;
public uint realTime;
public uint liveTime;
public uint dwellTime;
public pSpectrumHeaderStruct(int dummy)
{
spectrumNumber = new uint();
spectrumType = new uint();
spectrumLength = new uint();
startTime = new byte[8]; //the only
possibility for me to allocate memory for the byte streams
stopTime = new byte [8];
realTime = new uint();
liveTime = new uint();
dwellTime = new uint();
}
} //end of namespace pSpectrumHeaderStruct
{
.....
[DllImport("ComInterface.dll", EntryPoint = "SWI")]
......
Int64 rcx;
//pointer of dll data structure
pSpectrumHeaderStruct specHeader = new pSpectrumHeaderStruct(0);
//allocate memory for the data structure
SWI(ref rcx); // get pointer from
the dll
if (rcx != 0)
{
pSpectrumHeaderStruct sHeader;
sHeader = (pSpectrumHeaderStruct) Marshal.PtrToStructure( (IntPtr)
rcx, typeof(pSpectrumHeaderStruct)); // try to marshal get failed
!!!!!!!!!
sHeader = sHeader;
}
....
}
[\cpp]
I try to marshal following structure from a c++ dll to a c# smart device
application.
My problem is the BYTE stream. It woud not fill with data from the marshal
function PtrToStructure(). How can I fill the BYTE stream?
Thanks a lot,
elmar
c++ interface
[cpp]
typedef struct pHeaderData{
int spectrumNumber;
int spectrumType;
int spectrumLength;
BYTE startTime[8]; //bcd YYMMDDWWhhmmssHH
BYTE stopTime[8]; //bcd YYMMDDWWhhmmssHH
int realTime;
int liveTime;
int dwellTime;
}headerData;
c# part
public struct pSpectrumHeaderStruct
{
public uint spectrumNumber;
public uint spectrumType;
public uint spectrumLength;
public byte [] startTime;
public byte [] stopTime;
public uint realTime;
public uint liveTime;
public uint dwellTime;
public pSpectrumHeaderStruct(int dummy)
{
spectrumNumber = new uint();
spectrumType = new uint();
spectrumLength = new uint();
startTime = new byte[8]; //the only
possibility for me to allocate memory for the byte streams
stopTime = new byte [8];
realTime = new uint();
liveTime = new uint();
dwellTime = new uint();
}
} //end of namespace pSpectrumHeaderStruct
{
.....
[DllImport("ComInterface.dll", EntryPoint = "SWI")]
......
Int64 rcx;
//pointer of dll data structure
pSpectrumHeaderStruct specHeader = new pSpectrumHeaderStruct(0);
//allocate memory for the data structure
SWI(ref rcx); // get pointer from
the dll
if (rcx != 0)
{
pSpectrumHeaderStruct sHeader;
sHeader = (pSpectrumHeaderStruct) Marshal.PtrToStructure( (IntPtr)
rcx, typeof(pSpectrumHeaderStruct)); // try to marshal get failed
!!!!!!!!!
sHeader = sHeader;
}
....
}
[\cpp]