1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
//DOC MSDN C++: Utiliser
//
// I1 Entier signé sur 1 octet pour avoir un Boolean sur 1 octet de type C (true = 1, false = 0).
//
// Bool sur 4 octets . type BOOL Win32(true != 0, false = 0).
//
//VariantBool sur 2 octets . type BOOL OLE COM(true !=-1, false = 0).
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public struct MyStruct
{
//entier 8 octets comme int (4 octes pour short)
[MarshalAs(UnmanagedType.I8)]
public int a_;
[MarshalAs(UnmanagedType.I4)]
public int b_;
//reel 8 octets comme double(4 octets pour float)
[MarshalAs(UnmanagedType.R8)]
public double c_;
//utiliser I1 dans le cas d'un bool Type C(1 octet) dans ton cas
[MarshalAs(UnmanagedType.I1)]
public bool d_;
//utiliserBool dans le cas d'un bool de l'API WIN32(sur 4 octets)
[MarshalAs(UnmanagedType.Bool)]
public bool e_;
//utiliser VariantBool dans le cas d'un bool de l'OLE COM(sur 4 octets)
[MarshalAs(UnmanagedType.VariantBool)]
public bool f_;
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
} |
Partager