A
Arne Styve
Hi,
I have an API written in C that came with some graphics
cards we are going to use in a project. I need to write a
small application where this API is to be used, and I
decided to try out C#.
The API is imported by using the [DllImport("somedll.dll"-
method.
Now, the function in the DLL to call, has a parameter that
is a struct, which is fine, but one of the members of the
struct is a char-array:
in C:
typedef struct
{
unsigned short Size;
char DeviceName[16];
unsigned short DeviceType;
unsigned long Reserved0;
unsigned long Reserved1;
} VSWLOAD;
When creating a simelar struct in C# everything is fine
except for the char DeviceName[16];
How should a C# struct look like in order for it to be
possible to use as a parameter when calling the C-function
in the imported DLL ?
Also, the size-member of the struct should be initialized
with the entire size of the struct before calling the C-
function. In C this is done as follows:
VSWLOAD load;
load.Size = sizeof( VSWLOAD );
How do I get the size of the C# struct ?
Thanks for helping me out here. I'm really stuck here.
Regards
Arne
I have an API written in C that came with some graphics
cards we are going to use in a project. I need to write a
small application where this API is to be used, and I
decided to try out C#.
The API is imported by using the [DllImport("somedll.dll"-
method.
Now, the function in the DLL to call, has a parameter that
is a struct, which is fine, but one of the members of the
struct is a char-array:
in C:
typedef struct
{
unsigned short Size;
char DeviceName[16];
unsigned short DeviceType;
unsigned long Reserved0;
unsigned long Reserved1;
} VSWLOAD;
When creating a simelar struct in C# everything is fine
except for the char DeviceName[16];
How should a C# struct look like in order for it to be
possible to use as a parameter when calling the C-function
in the imported DLL ?
Also, the size-member of the struct should be initialized
with the entire size of the struct before calling the C-
function. In C this is done as follows:
VSWLOAD load;
load.Size = sizeof( VSWLOAD );
How do I get the size of the C# struct ?
Thanks for helping me out here. I'm really stuck here.
Regards
Arne