Click here to Skip to main content
16,004,991 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to avoid time span in dataset? Pin
pekhaleyogesh18-Nov-07 20:02
pekhaleyogesh18-Nov-07 20:02 
AnswerRe: How to avoid time span in dataset? Pin
J4amieC18-Nov-07 22:39
J4amieC18-Nov-07 22:39 
QuestionGridView and DeleteRow Pin
Jeffrey Walton18-Nov-07 18:05
Jeffrey Walton18-Nov-07 18:05 
AnswerRe: GridView and DeleteRow Pin
Abhijit Jana18-Nov-07 18:12
professionalAbhijit Jana18-Nov-07 18:12 
GeneralRe: GridView and DeleteRow Pin
Jeffrey Walton18-Nov-07 18:34
Jeffrey Walton18-Nov-07 18:34 
AnswerRe: GridView and DeleteRow Pin
Jeffrey Walton18-Nov-07 18:20
Jeffrey Walton18-Nov-07 18:20 
AnswerRe: GridView and DeleteRow Pin
Jeffrey Walton18-Nov-07 18:37
Jeffrey Walton18-Nov-07 18:37 
Questionstruct containing array of pointers to struct (C dll to C#) Pin
dfn18-Nov-07 16:31
dfn18-Nov-07 16:31 
Hi.
In C dll, there is a struct that contains an array of struct pointers. I do not know how to represent that in C#. That's my problem.

Here is the relevant C code:
struct vector
{
    uint elem_count;
    uint size;
    int (*cmp)(const void *, const void *);
    void *table;
};
 
typedef struct vector VECTOR;
 
#define CTABLE VECTOR
#define CSTATS VECTOR
 
struct cstream
{
    int mode;
    int byte_count;
    uchar *buff;
    int buff_len;
    int buff_pos;
    int bit_pos;
    bool growable;
    bool prepared;
    CTABLE *table[2];
    CSTATS *stats[3];
    uchar last_mode;
    int last_mode_offset;
};


And here is the C# code:
[UnmanagedFunctionPointer(CallingConvention.Winapi)  ]
        unsafe public delegate int cmp(IntPtr a, IntPtr b);
 
        [StructLayout(LayoutKind.Sequential, Pack = 1)]
        unsafe public struct VECTOR
        {
            public uint elem_count;
            public uint size;
            public uint elem_size;
            [MarshalAs(UnmanagedType.FunctionPtr)]
            public cmp cp; //C-func: public int (*cmp)(const void *, const void *);
            public IntPtr table;
        }
 
        [StructLayout(LayoutKind.Sequential, Pack = 1)]
        unsafe public struct CSTREAM
        {
            public int mode;
            public int byte_count;
            public IntPtr buff;
            public int buff_len;
            public int buff_pos;
            public int bit_pos;
            public bool growable;
            public bool prepared;
            public VECTOR[2]; // CTABLE *table[TTABLE_COUNT];
            public VECTOR[3]; // CSTATS *stats[STATS_COUNT];
            public byte last_mode;
            public int last_mode_offset;
        }
 
        [DllImport("compr.dll")]
        public static extern IntPtr screate(); // this function in C dll returns pointer to struct
 
        [DllImport("compr.dll")]
        public static extern IntPtr tcreate(); // this function in C dll returns pointer to struct; 


Now, I know how to get the IntPtr to a struct. For example:
MyClass.VECTOR stext = new MyClass.VECTOR();
IntPtr st = MyClass.screate();
stext = (MyClass.VECTOR)Marshal.PtrToStructure(st, typeof(MyClass.VECTOR)); 


However, I do not know how to represent, or work with, "CTABLE *table[2];" or "CSTATS *stats[3];" from the struct in C, in the C# struct (CSTREAM).
Does anyone know how to do this?
Thank you for any help.
Questioncombobox question Pin
NewToAspDotNet18-Nov-07 11:13
NewToAspDotNet18-Nov-07 11:13 
AnswerRe: combobox question Pin
Christian Graus18-Nov-07 11:34
protectorChristian Graus18-Nov-07 11:34 
QuestionErro wen sql server table has a empty value Pin
NewToAspDotNet18-Nov-07 10:42
NewToAspDotNet18-Nov-07 10:42 
AnswerRe: Erro wen sql server table has a empty value Pin
Pete O'Hanlon18-Nov-07 10:58
mvePete O'Hanlon18-Nov-07 10:58 
GeneralRe: Erro wen sql server table has a empty value Pin
NewToAspDotNet18-Nov-07 11:08
NewToAspDotNet18-Nov-07 11:08 
GeneralRe: Erro wen sql server table has a empty value Pin
Malcolm Smart18-Nov-07 11:38
Malcolm Smart18-Nov-07 11:38 
GeneralRe: Erro wen sql server table has a empty value Pin
echuck6618-Nov-07 15:35
echuck6618-Nov-07 15:35 
GeneralRe: Erro wen sql server table has a empty value Pin
Luis Alonso Ramos18-Nov-07 16:13
Luis Alonso Ramos18-Nov-07 16:13 
GeneralRe: Erro wen sql server table has a empty value Pin
Vasudevan Deepak Kumar18-Nov-07 17:29
Vasudevan Deepak Kumar18-Nov-07 17:29 
AnswerRe: Erro wen sql server table has a empty value Pin
Christian Graus18-Nov-07 11:37
protectorChristian Graus18-Nov-07 11:37 
QuestionPrevent DataGridView to populate rows at designtime [modified] Pin
Fayu18-Nov-07 9:46
Fayu18-Nov-07 9:46 
AnswerRe: Prevent DataGridView to populate rows at designtime Pin
Not Active18-Nov-07 10:04
mentorNot Active18-Nov-07 10:04 
QuestionStrongNameIdentityPermission - SNIP Pin
ekynox18-Nov-07 9:25
ekynox18-Nov-07 9:25 
QuestionHow to show Bitmap Pin
dataminers18-Nov-07 9:12
dataminers18-Nov-07 9:12 
AnswerRe: How to show Bitmap Pin
Not Active18-Nov-07 9:52
mentorNot Active18-Nov-07 9:52 
AnswerRe: How to show Bitmap Pin
Guffa18-Nov-07 10:00
Guffa18-Nov-07 10:00 
GeneralRe: How to show Bitmap Pin
dataminers18-Nov-07 10:06
dataminers18-Nov-07 10:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.