I did this with a double * instead of a byte *, so the code should be
similar.
The code is described below:
// C Code
typedef struct{
char ticker[32];
int date;
int ticks;
bool error;
int error_code;
char error_msg[256];
double *trades; // this is the one you're interested in
} onyx_timeseries_data;
// C# code
[Guid( "5B61E75A-1B38-4145-AF2E-5B64B28277F9" ), StructLayout(
LayoutKind.Sequential )]
public struct onyx_timeseries_data{
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]
public string ticker;
public int date;
public int ticks;
public bool error;
public int error_code;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=256)]
public string error_msg;
public IntPtr trades; // this is the one you're interested in
};
the function call is made like this:
LibWrap.onyx_timeseries_data data = new LibWrap.onyx_timeseries_data();
LibWrap.response_loop( connection, ref data );
and processed like this:
int count = data.ticks; //the number of items in data.trades;
unsafe{
double *arr = (double *) data.trades.ToPointer();
for( int i = 0; i < count; i++ ){
// do something with arr[ i ];
}
}
You should be able to access the data the same way.
> -----Original Message-----
> From: Dude [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 02, 2003 11:26 PM
> To: [EMAIL PROTECTED]
> Subject: [ADVANCED-DOTNET] System.Inptr problem
>
>
> I have a COM class which has the following function in one of
> its interface.
> HRESULT Decode([in] BSTR bstrEncodedData, [out] LONG *plSize,
> [out,size_is(,
> *plSize)] BYTE **ppbData);
>
> I created the wrapper class using Add Reference in solution
> explorer and the
> function COM definition now changed as follows in DOTNET.
> In Wrapper class
>
> void Decode ( string bstrData , int nSize , System.IntPtr ppData )
>
>
> As we can see..BYTE ** ppbData has been changed to
> System.IntPtr ppData.
>
>
> Now the problem is .How to call this Double pointer.in
> Dotnet......Any idea?
>
>
>
> I am using this code.........but I don't klnow how to access
> the return
> value from ptrOutPutData.
> I tried many ways but always I get some garbage values....
>
>
>
> ===========================================================
>
>
> private void Button1_Click(object sender, System.EventArgs e)
> {
>
>
> unsafe
> {
>
> byte[] pB = new byte[str.Length];
> int count;
>
> SomeFunction(ref pB, out count);
>
> ASCIIEncoding Encoding = new ASCIIEncoding();
> string content = Encoding.GetString(pB,0,count);
> MessageBox.Show(content);
> }
> }
>
>
> public unsafe void SomeFunction(ref byte[] buffer, out int count)
> {
>
> fixed (byte* p = buffer)
> {
> string str= TextBox4.Text;
>
> System.IntPtr ptrOutPutData = (System.IntPtr)p;
> count =0;
> SomeCOMClass obj = new SomeCOMClass();
>
> try
> {
> obj.Decode(str, out count, ptrOutPutData);
>
>
> }
> catch(Exception ee)
> {
> MessageBox.Show(ee.Message.ToString());
> }
>
> }
>
>
> }
>
> ===================================
> This list is hosted by DevelopMentor(r) http://www.develop.com
> NEW! ASP.NET courses you may be interested in:
>
> 2 Days of ASP.NET, 29 Sept 2003, in Redmond
> http://www.develop.com/courses/2daspdotnet
>
> Guerrilla ASP.NET, 13 Oct 2003, in Boston
> http://www.develop.com/courses/gaspdotnet
>
> View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor� http://www.develop.com
NEW! ASP.NET courses you may be interested in:
2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet
Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet
View archives and manage your subscription(s) at http://discuss.develop.com