调用api函数失败,怎么办?
下面是代码,怎么返回值就是零呢?
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
struct GLYPHSET
{
public int cbThis;
public int flAccel;
public int cGlyphsSupported;
public int cRanges;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=4)]
public byte[] wcRange ;
}
[DllImport("Gdi32")]
static extern int GetFontUnicodeRanges(
IntPtr hdc,
ref GLYPHSET lpgs);
void getFontRange(ref int rs, ref int re)
{
GLYPHSET ggg = new GLYPHSET();
ggg.cbThis = Marshal.SizeOf(typeof(GLYPHSET));
int k = GetFontUnicodeRanges(Handle,ref ggg);
rs = ggg.wcRange[0] << 8 + ggg.wcRange[1];
re = ggg.wcRange[2] << 8 + ggg.wcRange[3];
}