LOGFONT in C#
-
Hi friends & seniors, i have a Vc++ dll in which i return a struct of LOGFONT menbers
struct xyzStruct
{
LOGFONT a;
}extern "c" __dllspec ... xyzStruct a()
this data is populated in vc++ dll and passed to a C# form in the C# side i have created
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class LOGFONT
{
public int lfHeight = 0;
public int lfWidth = 0;
public int lfEscapement = 0;
public int lfOrientation = 0;
public int lfWeight = 0;
public byte lfItalic = 0;
public byte lfUnderline = 0;
public byte lfStrikeOut = 0;
public byte lfCharSet = 0;
public byte lfOutPrecision = 0;
public byte lfClipPrecision = 0;
public byte lfQuality = 0;
public byte lfPitchAndFamily = 0;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string lfFaceName = string.Empty;
}then i make pinvoke to the DLL
[StructLayout(LayoutKind.Sequential)]
public class xyzStruct
{
public lOGFONT a;
}
[dllImport ("Dll name")]
public static extern xyzStruct a();i get error "methods signature is not pinvoke comaptible" i try using int in struct in both dll and form everything works fine. thanks in advance Regards Samir
-
Hi friends & seniors, i have a Vc++ dll in which i return a struct of LOGFONT menbers
struct xyzStruct
{
LOGFONT a;
}extern "c" __dllspec ... xyzStruct a()
this data is populated in vc++ dll and passed to a C# form in the C# side i have created
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class LOGFONT
{
public int lfHeight = 0;
public int lfWidth = 0;
public int lfEscapement = 0;
public int lfOrientation = 0;
public int lfWeight = 0;
public byte lfItalic = 0;
public byte lfUnderline = 0;
public byte lfStrikeOut = 0;
public byte lfCharSet = 0;
public byte lfOutPrecision = 0;
public byte lfClipPrecision = 0;
public byte lfQuality = 0;
public byte lfPitchAndFamily = 0;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string lfFaceName = string.Empty;
}then i make pinvoke to the DLL
[StructLayout(LayoutKind.Sequential)]
public class xyzStruct
{
public lOGFONT a;
}
[dllImport ("Dll name")]
public static extern xyzStruct a();i get error "methods signature is not pinvoke comaptible" i try using int in struct in both dll and form everything works fine. thanks in advance Regards Samir
-
Hi friends & seniors, i have a Vc++ dll in which i return a struct of LOGFONT menbers
struct xyzStruct
{
LOGFONT a;
}extern "c" __dllspec ... xyzStruct a()
this data is populated in vc++ dll and passed to a C# form in the C# side i have created
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class LOGFONT
{
public int lfHeight = 0;
public int lfWidth = 0;
public int lfEscapement = 0;
public int lfOrientation = 0;
public int lfWeight = 0;
public byte lfItalic = 0;
public byte lfUnderline = 0;
public byte lfStrikeOut = 0;
public byte lfCharSet = 0;
public byte lfOutPrecision = 0;
public byte lfClipPrecision = 0;
public byte lfQuality = 0;
public byte lfPitchAndFamily = 0;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string lfFaceName = string.Empty;
}then i make pinvoke to the DLL
[StructLayout(LayoutKind.Sequential)]
public class xyzStruct
{
public lOGFONT a;
}
[dllImport ("Dll name")]
public static extern xyzStruct a();i get error "methods signature is not pinvoke comaptible" i try using int in struct in both dll and form everything works fine. thanks in advance Regards Samir
Please Reformat your code to make it readability use Code-Block to Wrap your code. :)