Bonjour,
J'ai un Outil C# qui importe une DLL C.
En effet, j'ai une exception "Attempted to read or write protected memory. This is often an indication that other memory has been corrupted".
J'ai besoin d'une aide !!
Déjà, je vous montre la fonction en C avec une structure.
INT16 G_DECL G_DSO_GetWaveDescriptor (const WORD16 DeviceHandle,const char * const TraceIdentifier,WF_DESCRIPTOR * const Descriptor);
typedef struct
{
WORD32 SweepsPerAcq;
double HorizOffset;
char HorizUnit[48];
WORD8 TrigerTimeMinutes;
float AcqVertOffset;
WORD16 WaveSource;
} WF_DESCRIPTOR;
Dans le code C#, voici comment sont déclarées les fonctions de la DLL :
[DllImport("C:/WINDOWS/system32/w32gdso.dll")]
internal static extern Int16 G_DSO_GetWaveDescriptor(short device, string voix, ref WF_DESCRIPTOR Descriptor);
[StructLayout(LayoutKind.Sequential)]
public struct WF_DESCRIPTOR{
[MarshalAs(UnmanagedType.I4)]
public Int32 SweepsPerAcq;
[MarshalAs(UnmanagedType.R8)]
public Double HorizOffset;
[MarshalAs(UnmanagedType.ByValArray,SizeConst = 48)]
public string[] HorizUnit;
[MarshalAs(UnmanagedType.I1)]
public Byte TrigerTimeMinutes;
[MarshalAs(UnmanagedType.R4)]
public Single AcqVertOffset;
[MarshalAs(UnmanagedType.I2)]
public Int16 WaveSource;
}
Appel des fonctions :
WF_DESCRIPTOR DESCRIPTOR = new WF_DESCRIPTOR();
Int16 res = G_DSO_GetWaveDescriptor(0, "C1", ref DESCRIPTOR );
Big merci d'avance !!