读写ini文件

  <script>window.onerror = function() { return true; };</script> body {margin:0;overflow:auto;font:normal 14px Verdana;background:#fff;padding:2px 4px 0;}body, p, font, div, li { line-height: 150%;}body, td, th {color:#000000;}.i {width:100%;*width:auto;table-layout:fixed;}pre {white-space: pre-wrap;white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap;word-wrap: break-word;}a { color: -moz-hyperlinktext !important;text-decoration: -moz-anchor-decoration;}

 /// <summary>
        /// 读写ini文件
        /// </summary>
        /// <param name="lpApplicationName"></param>
        /// <param name="lpKeyName"></param>
        /// <param name="nDefault"></param>
        /// <param name="lpFileName"></param>
        /// <returns></returns>
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileInt(string lpApplicationName, string lpKeyName, int nDefault, string lpFileName);
        [DllImport("kernel32")]
        private static extern bool GetPrivateProfileString(string lpApplicationName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
        [DllImport("kernel32")]
        private static extern bool WritePrivateProfileString(string lpApplicationName, string lpKeyName, string lpString, string lpFileName);
        [DllImport("kernel32")]
        private static extern bool GetPrivateProfileSection(string lpAppName, string lpReturnedString, int nSize, string lpFileName);
        [DllImport("kernel32")]
        private static extern bool WritePrivateProfileSection(string lpAppName, string lpString, string lpFileName);
        public const int MAX_PATH = 256;
        public  string FILE_NAME = Application.StartupPath + " //SetTitle.ini ";
 
  //读取ini文件来显示软件标题栏内容
                //if (File.Exists(FILE_NAME))
                //{
                //    StringBuilder strCaption = new StringBuilder(256);
                //    GetPrivateProfileString("Form", "Caption", "Default Caption", strCaption, strCaption.Capacity, FILE_NAME);
                //    this.Text = strCaption.ToString();
                //    //int myWidth = GetPrivateProfileInt("Form", "Width", this.Width, FILE_NAME);
                //    //this.Width = myWidth;
                //    //int myHeight = GetPrivateProfileInt("Form", "Height", this.Height, FILE_NAME);
                //    //this.Height = myHeight;
                //    //int myLeft = GetPrivateProfileInt("Form", "Left", this.Left, FILE_NAME);
                //    //this.Left = myLeft;
                //    //int myTop = GetPrivateProfileInt("Form", "Top", this.Top, FILE_NAME);
                //    //this.Top = myTop;
                //}
 
//写入ini文件
//string strCaption = txtTitle.Text;
                    //WritePrivateProfileString("Form", "Caption", strCaption, FILE_NAME);
 //string strCaption = "CELL积分系统";
                    //WritePrivateProfileString("Form", "Caption", strCaption, FILE_NAME);
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值