BOOL b;
 
SystemParametersInfo(0x0060, TRUE, &b, NULL);如上的格式...在C#中该如何定义和使用呢???

解决方案 »

  1.   

    NONCLIENTMETRICS nm;  SystemParametersInfo(0x0029,sizeof(nm),&nm,0);还有这一种! 结构体NONCLIENTMETRICS已经定义好了...就是不知道这种形式的SystemParametersInfo在C#中又如何怎样定义...郁闷,SystemParametersInfo究竟有多少种重载方式...请各位指点...
      

  2.   

    [DllImport("user32.dll", EntryPoint="SystemParametersInfo")]
    public static extern int SystemParametersInfo (
    int uAction,
    int uParam,
    ref int lpvParam,
    int fuWinIni
    );[StructLayout(LayoutKind.Sequential)]
    public struct NONCLIENTMETRICS {
    public int cbSize;
    public int iBorderWidth;
    public int iScrollWidth;
    public int iScrollHeight;
    public int iCaptionWidth;
    public int iCaptionHeight;
    public LOGFONT lfCaptionFont;
    public int iSMCaptionWidth;
    public int iSMCaptionHeight;
    public LOGFONT lfSMCaptionFont;
    public int iMenuWidth;
    public int iMenuHeight;
    public LOGFONT lfMenuFont;
    public LOGFONT lfStatusFont;
    public LOGFONT lfMessageFont;
    }
      

  3.   

    感谢楼上...具体调用怎样写...主要是这一段不明白怎样传进去: sizeof(nm),&nm有C#中使用sizeof时报错了...
      

  4.   

    哪一项需要用sizeof?
    如果一定要用sizeof,就项目属性里。选中:允许不安全代码。
      

  5.   

    它的写法是这样...
    SystemParametersInfo(0x0029,sizeof(nm),&nm,0);我不明白怎样把结构体nm传进去.是ref nm.GetHashCode()吗???
      

  6.   

    最好把SystemParametersInfo(0x0029,sizeof(nm),&nm,0);翻成C#的...嘻嘻...
      

  7.   

    [DllImport("user32.dll", EntryPoint="SystemParametersInfo")]
    public static extern int SystemParametersInfo (
    int uAction,
    int uParam,
    ref NONCLIENTMETRICS lpvParam,
    int fuWinIni
    );
      

  8.   

    能不用API解决最好别用APISystem.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.PMDesignator;
      

  9.   

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
            private struct LOGFONT
            {
                public int lfHeight;
                public int lfWidth;
                public int lfEscapement;
                public int lfOrientation;
                public int lfWeight;
                public byte lfItalic;
                public byte lfUnderline;
                public byte lfStrikeOut;
                public byte lfCharSet;
                public byte lfOutPrecision;
                public byte lfClipPrecision;
                public byte lfQuality;
                public byte lfPitchAndFamily;
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
                public string lfFaceSize;
            }        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
            private struct NONCLIENTMETRICS
            {
                public int cbSize;
                public int iBorderWidth;
                public int iScrollWidth;
                public int iScrollHeight;
                public int iCaptionWidth;
                public int iCaptionHeight;
                public LOGFONT lfCaptionFont;
                public int iSmCaptionWidth;
                public int iSmCaptionHeight;
                public LOGFONT lfSmCaptionFont;
                public int iMenuWidth;
                public int iMenuHeight;
                public LOGFONT lfMenuFont;
                public LOGFONT lfStatusFont;
                public LOGFONT lfMessageFont;
            }         const int SPI_GETNONCLIENTMETRICS = 0x0029;
            const int SPI_SETNONCLIENTMETRICS = 0x002A;        [DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
    private static extern bool SystemParametersInfo(int uiAction, int uiParam,
    ref NONCLIENTMETRICS ncMetrics, int fWinIni);        private void button4_Click(object sender, EventArgs e)
            {
                NONCLIENTMETRICS nm = new NONCLIENTMETRICS();
                int nSize = Marshal.SizeOf(nm);
                nm.cbSize = nSize;
                SystemParametersInfo(SPI_GETNONCLIENTMETRICS, nSize, ref nm, 0);
                nm.iCaptionHeight = 20;
                SystemParametersInfo(SPI_SETNONCLIENTMETRICS, nSize, ref nm, 0);
                //GetCaptionFont();
            }