T
Tremendo
[I posted this in ...dotnet.framework.interop last week, with no luck. The question seems long, but
I think that the answer should be easy and quick for someone who knows it.]
Hi,
I need to consume an unmanaged DLL from managed C#. The DLL is "ae766.dll". I have problems with one
function in it. Who developed the DLL, provided the following information, regarding that function:
-----------------------------
Declaration
-----------------------------
extern "C" long __stdcall GetAnalyzerTraceData(LPSAFEARRAY FAR *);
-----------------------------
Description of the function
-----------------------------
GetAnalyzerTraceData(LPSAFEARRAY FAR *);
A call to this routine will result in one trace of data being returned. A pointer to an array of
BYTE type (in Visual Basic) should be passed in. This array
will be allocated, initialized, and the data from the unit will be located in it as binary data.
The structure of the data is as follows:
Struct Data
{
char freq[7]; //center frequency (ascii characters) in units of kHz
char span; //Decimal index indicating the current span
char ref_level; //Decimal index indicating the current reference level
char RBW[7]; //ascii characters indicating the current RBW
unsigned char data[1000];
unsigned char checksum; //checksum of the bytes
unsigned char reserved; //unused
}
The total length of the data is 1018 bytes. The “data” portion of the structure is the actual trace
data.
A return value of 1 indicates success. A return value of 0 indicates a failure while attempting to
read from the GSA-810.
-----------------------------
What C# code do I need to write, to "translate" the struct and to import the function? You don't
need to write the whole code for me, because there are repeated data types (inside the struct, for
instance). A hint about how to do it should be enough.
Thank you very much.
I think that the answer should be easy and quick for someone who knows it.]
Hi,
I need to consume an unmanaged DLL from managed C#. The DLL is "ae766.dll". I have problems with one
function in it. Who developed the DLL, provided the following information, regarding that function:
-----------------------------
Declaration
-----------------------------
extern "C" long __stdcall GetAnalyzerTraceData(LPSAFEARRAY FAR *);
-----------------------------
Description of the function
-----------------------------
GetAnalyzerTraceData(LPSAFEARRAY FAR *);
A call to this routine will result in one trace of data being returned. A pointer to an array of
BYTE type (in Visual Basic) should be passed in. This array
will be allocated, initialized, and the data from the unit will be located in it as binary data.
The structure of the data is as follows:
Struct Data
{
char freq[7]; //center frequency (ascii characters) in units of kHz
char span; //Decimal index indicating the current span
char ref_level; //Decimal index indicating the current reference level
char RBW[7]; //ascii characters indicating the current RBW
unsigned char data[1000];
unsigned char checksum; //checksum of the bytes
unsigned char reserved; //unused
}
The total length of the data is 1018 bytes. The “data” portion of the structure is the actual trace
data.
A return value of 1 indicates success. A return value of 0 indicates a failure while attempting to
read from the GSA-810.
-----------------------------
What C# code do I need to write, to "translate" the struct and to import the function? You don't
need to write the whole code for me, because there are repeated data types (inside the struct, for
instance). A hint about how to do it should be enough.
Thank you very much.