Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

gmar

@gmar
About
Posts
5
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • c# Marshalling unmanaged type char[xx]
    G gmar

    So here is the method to get data correctly [MarshalAs(UnmanagedType.ByValArray,SizeConst=10)] public byte [] mystring1; instead of [MarshalAs(UnmanagedType.ByValStr,SizeConst=10)] public string mystring1; i guess this will be ok in your application

    C# help csharp c++ question

  • c# Marshalling unmanaged type char[xx]
    G gmar

    hello, i already tried to set CharSet=CharSet.Ansi, but it didn't change anything. Unsafe or not shouldn't be a problem, but i will remove it just to try. and as you have seen i'm not talking about a problem on Data3, my problem is to get back the content of each char array coming from my dll. so i will try to get it back as an array of byte , if it's possible. So if you have a real idea about how to solve this problem, you are welcome.

    C# help csharp c++ question

  • c# Marshalling unmanaged type char[xx]
    G gmar

    Fucntion declared in the dll like this INT Function(DWORD param1, mystruct *psConfig); import with c# [DllImport(@"C:\DLL\MyDll.dll",EntryPoint="Function")] unsafe public static extern int MyFunction(uint param1,ref mystruct psConfig); Calling function : private void button10_Click(object sender, System.EventArgs e) { mystruct sConfig = new mystruct(); int res; unsafe { res = MyFunction(hCom,ref sConfig); } MessageBox.Show( res.ToString() ); }

    C# help csharp c++ question

  • c# Marshalling unmanaged type char[xx]
    G gmar

    So here is my problem : i have a structure used as parameter (struct * )in a dll (VC++ 6.00): typedef struct { CHAR chararray1[10]; DWORD Data1; DWORD Data2; CHAR chararray2[4]; CHAR chararray3[2]; BYTE Data3; BYTE Data4; BYTE Data5; BYTE Data6; BYTE Data7; BYTE Data8; } mystruct; It should be converted like this - i think ;-)) - [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi)] unsafe public struct mystruct { [MarshalAs(UnmanagedType.ByValTStr,SizeConst=10)] public string chararray1; public Int32 Data1; public Int32 Data2; [MarshalAs(UnmanagedType.ByValTStr,SizeConst=4)] public string chararray2; [MarshalAs(UnmanagedType.ByValTStr,SizeConst=2)] public string chararray3; public byte Data4; public byte Data5; ... } Expected Value for string fields are "ABC : 0.00", "1234", "56" When executing with size defined identically in both structures, i get this strange result "ABC :0.0","123", "5" if i increase(+1) the size in C# structure , hoping to get my missing char, i get "ABC : 0.00", "1234", "6" So am i doing a mistake somewhere ? or is it a bug ?????? Thanks by Advance Gaetan

    C# help csharp c++ question

  • DLL import and parameters
    G gmar

    ;)Hello, i'm using a dll with VC++ 6.0 i would like to use it with C#. My problem is that some type of data are not usable with c#. For exemple i can use char *xx as parameter , but when i want to use a pointer on a structure, it seems impossible to have it working. MyStruct { string field1; int field2; } [DllImport(@"C:\DLL\MyDll.dll",EntryPoint="myfunction",CharSet=CharSet.Ansi)] unsafe public static extern int myfunction(uint param1,short short param2, MyStruct *pointeronStruct); It is not working, [DllImport(@"C:\DLL\MyDll.dll",EntryPoint="ReadCard",CharSet=CharSet.Ansi)] unsafe public static extern int SecondFunction(uint param1,short param2, byte *field1, int *field2); so i need to split the structure, when there is only 2 fields, it's not a problem, but when you have 10 fields, it's not the same. As i cannot modify the dll, i decided to include this dll in a dll where is solve thoses kind of problem and then use the new dll with .NET. Does someone know how to solve this ? Thanks by advance

    C# csharp c++ help tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups