Example #1
0
 /// <summary>
 /// 读取数据级别的Byte数组
 /// </summary>
 /// <param name="Sections"></param>
 /// <param name="Key"></param>
 /// <param name="Length"></param>
 /// <returns></returns>
 public byte[] ReadByteArray(string Sections, string Key, int Length)
 {
     byte[] buffer1;
     if (Length > 0)
     {
         try
         {
             byte[] buffer2 = new byte[(Length - 1) + 1];
             if (INIFileHelper.GetPrivateProfileStruct(Sections, Key, buffer2, buffer2.Length, this.Filename) == 0)
             {
                 return(null);
             }
             return(buffer2);
         }
         catch (Exception exception1)
         {
             ProjectData.SetProjectError(exception1);
             buffer1 = null;
             ProjectData.ClearProjectError();
             return(buffer1);
         }
     }
     else
     {
         return(null);
     }
 }
Example #2
0
        public ArrayList GetSectionsNames()
        {
            int       num1;
            ArrayList list1 = new ArrayList();

            byte[] buffer1 = new byte[MAX_ENTRY];
            int    num2    = 0;

            try
            {
                num1 = INIFileHelper.GetPrivateProfileSectionsNames(buffer1, MAX_ENTRY, this.Filename);
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                ProjectData.ClearProjectError();
                return(list1);
            }
            ASCIIEncoding encoding1 = new ASCIIEncoding();

            if (num1 > 0)
            {
                string text1 = encoding1.GetString(buffer1);
                num1 = 0;
                num2 = -1;
                while (true)
                {
                    num1 = text1.IndexOf('\0', (int)(num2 + 1));
                    if (((num1 - num2) == 1) || (num1 == -1))
                    {
                        return(list1);
                    }
                    try
                    {
                        list1.Add(text1.Substring(num2 + 1, num1 - num2));
                    }
                    catch (Exception exception2)
                    {
                        ProjectData.SetProjectError(exception2);
                        ProjectData.ClearProjectError();
                    }
                    num2 = num1;
                }
            }
            return(list1);
        }
Example #3
0
        public bool DeleteSections(string Section)
        {
            bool flag1;

            try
            {
                flag1 = INIFileHelper.WritePrivateProfileSections(Sections, null, this.Filename) != 0;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                flag1 = false;
                ProjectData.ClearProjectError();
                return(flag1);
            }
            return(flag1);
        }
Example #4
0
        public bool Write(string Sections, string Key, string Value)
        {
            bool flag1;

            try
            {
                flag1 = INIFileHelper.WritePrivateProfileString(Sections, Key, Value, this.Filename) != 0;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                flag1 = false;
                ProjectData.ClearProjectError();
                return(flag1);
            }
            return(flag1);
        }
Example #5
0
        public int ReadInteger(string Sections, string Key, int DefaultValue)
        {
            int num1;

            try
            {
                num1 = INIFileHelper.GetPrivateProfileInt(Sections, Key, DefaultValue, this.Filename);
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                num1 = DefaultValue;
                ProjectData.ClearProjectError();
                return(num1);
            }
            return(num1);
        }
Example #6
0
        /// <summary>
        /// 运用DLL引入的方法读取INI配置文件的信息
        /// </summary>
        /// <param name="Sections"></param>
        /// <param name="Key"></param>
        /// <param name="DefaultValue"></param>
        /// <returns></returns>
        public string ReadString(string Sections, string Key, string DefaultValue)
        {
            string text1;

            try
            {
                StringBuilder builder1 = new StringBuilder(MAX_ENTRY);
                int           num1     = INIFileHelper.GetPrivateProfileString(Sections, Key, DefaultValue, builder1, MAX_ENTRY, this.Filename);
                text1 = builder1.ToString();
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                text1 = DefaultValue;
                ProjectData.ClearProjectError();
                return(text1);
            }
            return(text1);
        }