⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inimgr.pas

📁 MiniHex 1.1 源程序说明 “MiniHex11SrcSource”目录中的所有文件是MiniHex 1.1的主程序; “MiniHex11SrcControls”目录中的是该软件
💻 PAS
字号:
unit IniMgr;

interface

uses
  Windows, Messages, SysUtils, Classes,
  Forms, IniFiles, Graphics, OptionFrm,
  ToolsMgrFrm;

type

  TIniMgr = class
  private
    FFileName: string;

  public
    constructor Create(IniFileName: string);

    procedure SaveOptions(var OptionData: TOptionData);
    procedure LoadOptions(var OptionData: TOptionData);

    procedure SaveFormRect(Value: TRect);
    procedure LoadFormRect(var Value: TRect);

  end;

var
  IniManager: TIniMgr;

implementation

uses HexChFrm, Misc;

constructor TIniMgr.Create(IniFileName: string);
begin
  FFileName := GetIniFileName;
end;

procedure TIniMgr.LoadOptions(var OptionData: TOptionData);
var
  Ini: TIniFile;
  Section: string;
begin
  Ini := TIniFile.Create(FFileName);
  SetDefaultOptions(OptionData);
  Section := 'Options';
  OptionData.AddrColor.FColor := Ini.ReadInteger(Section, 'AddrColorF', OptionData.AddrColor.FColor);
  OptionData.AddrColor.BColor := Ini.ReadInteger(Section, 'AddrColorB', OptionData.AddrColor.BColor);
  OptionData.HexColor.FColor := Ini.ReadInteger(Section, 'HexColorF', OptionData.HexColor.FColor);
  OptionData.HexColor.BColor := Ini.ReadInteger(Section, 'HexColorB', OptionData.HexColor.BColor);
  OptionData.ChrColor.FColor := Ini.ReadInteger(Section, 'ChrColorF', OptionData.ChrColor.FColor);
  OptionData.ChrColor.BColor := Ini.ReadInteger(Section, 'ChrColorB', OptionData.ChrColor.BColor);
  OptionData.CurItemColor.FColor := Ini.ReadInteger(Section, 'CurItemColorF', OptionData.CurItemColor.FColor);
  OptionData.CurItemColor.BColor := Ini.ReadInteger(Section, 'CurItemColorB', OptionData.CurItemColor.BColor);
  OptionData.BlockColor.FColor := Ini.ReadInteger(Section, 'BlockColorF', OptionData.BlockColor.FColor);
  OptionData.BlockColor.BColor := Ini.ReadInteger(Section, 'BlockColorB', OptionData.BlockColor.BColor);

  OptionData.ShowToolBar := Ini.ReadBool(Section, 'ShowToolBar', OptionData.ShowToolBar);
  OptionData.ShowStatusBar := Ini.ReadBool(Section, 'ShowStatusBar', OptionData.ShowStatusBar);
  OptionData.ShowDataInsp := Ini.ReadBool(Section, 'ShowDataInsp', OptionData.ShowDataInsp);
  OptionData.OnTop:= Ini.ReadBool(Section, 'OnTop', OptionData.OnTop);

  OptionData.StatusLengthRadix := TRadix(Ini.ReadInteger(Section, 'StatusLengthRadix', Integer(OptionData.StatusLengthRadix)));
  OptionData.StatusOffsetRadix := TRadix(Ini.ReadInteger(Section, 'StatusOffsetRadix', Integer(OptionData.StatusOffsetRadix)));
  OptionData.StatusBlockInfoRadix := TRadix(Ini.ReadInteger(Section, 'StatusBlockInfoRadix', Integer(OptionData.StatusBlockInfoRadix)));
  OptionData.StatusCurValueType := TValueType(Ini.ReadInteger(Section, 'StatusCurValueType', Integer(OptionData.StatusCurValueType)));

  OptionData.HexEditFont.Name := Ini.ReadString(Section, 'HexEditFontName', OptionData.HexEditFont.Name);
  OptionData.HexEditFont.Size := Ini.ReadInteger(Section, 'HexEditFontSize', OptionData.HexEditFont.Size);
  OptionData.HexEditFont.Charset := TFontCharset(Ini.ReadInteger(Section, 'HexEditFontCharset', OptionData.HexEditFont.Charset));
  OptionData.HexEditFont.Height := Ini.ReadInteger(Section, 'HexEditFontHeight', OptionData.HexEditFont.Height);
  OptionData.HexEditFont.Color := TColor(Ini.ReadInteger(Section, 'HexEditFontColor', OptionData.HexEditFont.Color));
  if (Ini.ReadBool(Section, 'HexEditFontB', False)) then
    OptionData.HexEditFont.Style := OptionData.HexEditFont.Style + [fsBold];
  if (Ini.ReadBool(Section, 'HexEditFontI', False)) then
    OptionData.HexEditFont.Style := OptionData.HexEditFont.Style + [fsItalic];
  if (Ini.ReadBool(Section, 'HexEditFontU', False)) then
    OptionData.HexEditFont.Style := OptionData.HexEditFont.Style + [fsUnderline];

  OptionData.AutoShowOpen := Ini.ReadBool(Section, 'AutoShowOpen', OptionData.AutoShowOpen);
  OptionData.AddContextMenu := Ini.ReadBool(Section, 'AddContextMenu', OptionData.AddContextMenu);
  OptionData.AllowMultiIns := Ini.ReadBool(Section, 'AllowMultiIns', OptionData.AllowMultiIns);
  OptionData.ShowDot := Ini.ReadBool(Section, 'ShowDot', OptionData.ShowDot);
  OptionData.SaveWinSize := Ini.ReadBool(Section, 'SaveWinSize', OptionData.SaveWinSize);
  OptionData.TempPath := Ini.ReadString(Section, 'TempPath', OptionData.TempPath);
  OptionData.DefEditor := Ini.ReadString(Section, 'DefEditor', OptionData.DefEditor);
  OptionData.DblClickAct := TDblClickAct(Ini.ReadInteger(Section, 'DblClickAct', Integer(OptionData.DblClickAct)));
  OptionData.MinState := TMinState(Ini.ReadInteger(Section, 'MinState', Integer(OptionData.MinState)));

  OptionData.AskSave := Ini.ReadBool(Section, 'AskSave', OptionData.AskSave);
  OptionData.CreateBak := Ini.ReadBool(Section, 'CreateBak', OptionData.CreateBak);
  OptionData.AskWriteSector := Ini.ReadBool(Section, 'AskWriteSector', OptionData.AskWriteSector);
  OptionData.AskWriteCMOS := Ini.ReadBool(Section, 'AskWriteCMOS', OptionData.AskWriteCMOS);
  OptionData.MaxUndo := Ini.ReadInteger(Section, 'MaxUndo', OptionData.MaxUndo);

  OptionData.ShowDataInsp := Ini.ReadBool(Section, 'ShowDataInsp', OptionData.SaveWinSize);
  OptionData.ShowU8Data := Ini.ReadBool(Section, 'ShowU8Data', OptionData.ShowU8Data);
  OptionData.ShowS8Data := Ini.ReadBool(Section, 'ShowS8Data', OptionData.ShowS8Data);
  OptionData.ShowU16Data := Ini.ReadBool(Section, 'ShowU16Data', OptionData.ShowU16Data);
  OptionData.ShowS16Data := Ini.ReadBool(Section, 'ShowS16Data', OptionData.ShowS16Data);
  OptionData.ShowU32Data := Ini.ReadBool(Section, 'ShowU32Data', OptionData.ShowU32Data);
  OptionData.ShowS32Data := Ini.ReadBool(Section, 'ShowS32Data', OptionData.ShowS32Data);
  OptionData.ShowS64Data := Ini.ReadBool(Section, 'ShowS64Data', OptionData.ShowS64Data);
  OptionData.ShowSingleData := Ini.ReadBool(Section, 'ShowSingleData', OptionData.ShowSingleData);
  OptionData.ShowDoubleData := Ini.ReadBool(Section, 'ShowDoubleData', OptionData.ShowDoubleData);
  OptionData.ShowReal48Data := Ini.ReadBool(Section, 'ShowReal48Data', OptionData.ShowReal48Data);
  OptionData.ShowBinaryData := Ini.ReadBool(Section, 'ShowBinaryData', OptionData.ShowBinaryData);
  OptionData.DefDataInspPos := TDefDataInspPos(Ini.ReadInteger(Section, 'DefDataInspPos', Integer(OptionData.DefDataInspPos)));

  Ini.Free;
end;

procedure TIniMgr.SaveOptions(var OptionData: TOptionData);
var
  Ini: TIniFile;
  Section: string;
begin
  Ini := TIniFile.Create(FFileName);
  Section := 'Options';
  Ini.WriteInteger(Section, 'AddrColorF', OptionData.AddrColor.FColor);
  Ini.WriteInteger(Section, 'AddrColorB', OptionData.AddrColor.BColor);
  Ini.WriteInteger(Section, 'HexColorF', OptionData.HexColor.FColor);
  Ini.WriteInteger(Section, 'HexColorB', OptionData.HexColor.BColor);
  Ini.WriteInteger(Section, 'ChrColorF', OptionData.ChrColor.FColor);
  Ini.WriteInteger(Section, 'ChrColorB', OptionData.ChrColor.BColor);
  Ini.WriteInteger(Section, 'CurItemColorF', OptionData.CurItemColor.FColor);
  Ini.WriteInteger(Section, 'CurItemColorB', OptionData.CurItemColor.BColor);
  Ini.WriteInteger(Section, 'BlockColorF', OptionData.BlockColor.FColor);
  Ini.WriteInteger(Section, 'BlockColorB', OptionData.BlockColor.BColor);

  Ini.WriteBool(Section, 'ShowToolBar', OptionData.ShowToolBar);
  Ini.WriteBool(Section, 'ShowStatusBar', OptionData.ShowStatusBar);
  Ini.WriteBool(Section, 'ShowDataInsp', OptionData.ShowDataInsp);
  Ini.WriteBool(Section, 'OnTop', OptionData.OnTop);

  Ini.WriteInteger(Section, 'StatusLengthRadix', Integer(OptionData.StatusLengthRadix));
  Ini.WriteInteger(Section, 'StatusOffsetRadix', Integer(OptionData.StatusOffsetRadix));
  Ini.WriteInteger(Section, 'StatusBlockInfoRadix', Integer(OptionData.StatusBlockInfoRadix));
  Ini.WriteInteger(Section, 'StatusCurValueType', Integer(OptionData.StatusCurValueType));

  Ini.WriteString(Section, 'HexEditFontName', OptionData.HexEditFont.Name);
  Ini.WriteInteger(Section, 'HexEditFontSize', OptionData.HexEditFont.Size);
  Ini.WriteInteger(Section, 'HexEditFontCharset', OptionData.HexEditFont.Charset);
  Ini.WriteInteger(Section, 'HexEditFontHeight', OptionData.HexEditFont.Height);
  Ini.WriteInteger(Section, 'HexEditFontColor', OptionData.HexEditFont.Color);
  Ini.WriteBool(Section, 'HexEditFontB', fsBold in OptionData.HexEditFont.Style);
  Ini.WriteBool(Section, 'HexEditFontI', fsItalic in OptionData.HexEditFont.Style);
  Ini.WriteBool(Section, 'HexEditFontU', fsUnderline in OptionData.HexEditFont.Style);

  Ini.WriteBool(Section, 'AutoShowOpen', OptionData.AutoShowOpen);
  Ini.WriteBool(Section, 'AddContextMenu', OptionData.AddContextMenu);
  Ini.WriteBool(Section, 'AllowMultiIns', OptionData.AllowMultiIns);
  Ini.WriteBool(Section, 'ShowDot', OptionData.ShowDot);
  Ini.WriteBool(Section, 'SaveWinSize', OptionData.SaveWinSize);
  Ini.WriteString(Section, 'TempPath', OptionData.TempPath);
  Ini.WriteString(Section, 'DefEditor', OptionData.DefEditor);
  Ini.WriteInteger(Section, 'DblClickAct', Integer(OptionData.DblClickAct));
  Ini.WriteInteger(Section, 'MinState', Integer(OptionData.MinState));

  Ini.WriteBool(Section, 'AskSave', OptionData.AskSave);
  Ini.WriteBool(Section, 'CreateBak', OptionData.CreateBak);
  Ini.WriteBool(Section, 'AskWriteSector', OptionData.AskWriteSector);
  Ini.WriteBool(Section, 'AskWriteCMOS', OptionData.AskWriteCMOS);
  Ini.WriteInteger(Section, 'MaxUndo', Integer(OptionData.MaxUndo));

  Ini.WriteBool(Section, 'ShowDataInsp', OptionData.ShowDataInsp);
  Ini.WriteBool(Section, 'ShowU8Data', OptionData.ShowU8Data);
  Ini.WriteBool(Section, 'ShowS8Data', OptionData.ShowS8Data);
  Ini.WriteBool(Section, 'ShowU16Data', OptionData.ShowU16Data);
  Ini.WriteBool(Section, 'ShowS16Data', OptionData.ShowS16Data);
  Ini.WriteBool(Section, 'ShowU32Data', OptionData.ShowU32Data);
  Ini.WriteBool(Section, 'ShowS32Data', OptionData.ShowS32Data);
  Ini.WriteBool(Section, 'ShowS64Data', OptionData.ShowS64Data);
  Ini.WriteBool(Section, 'ShowSingleData', OptionData.ShowSingleData);
  Ini.WriteBool(Section, 'ShowDoubleData', OptionData.ShowDoubleData);
  Ini.WriteBool(Section, 'ShowReal48Data', OptionData.ShowReal48Data);
  Ini.WriteBool(Section, 'ShowBinaryData', OptionData.ShowBinaryData);
  Ini.WriteInteger(Section, 'DefDataInspPos', Integer(OptionData.DefDataInspPos));

  Ini.Free;
end;

procedure TIniMgr.SaveFormRect(Value: TRect);
var
  Ini: TIniFile;
  Section: string;
begin
  Ini := TIniFile.Create(FFileName);
  Section := 'Options';
  Ini.WriteInteger(Section, 'FormLeft', Value.Left);
  Ini.WriteInteger(Section, 'FormTop', Value.Top);
  Ini.WriteInteger(Section, 'FormRight', Value.Right);
  Ini.WriteInteger(Section, 'FormBottom', Value.Bottom);
  Ini.Free;
end;

procedure TIniMgr.LoadFormRect(var Value: TRect);
var
  Ini: TIniFile;
  Section: string;
begin
  Ini := TIniFile.Create(FFileName);
  Section := 'Options';
  Value.Left := Ini.ReadInteger(Section, 'FormLeft', Value.Left);
  Value.Top := Ini.ReadInteger(Section, 'FormTop', Value.Top);
  Value.Right := Ini.ReadInteger(Section, 'FormRight', Value.Right);
  Value.Bottom := Ini.ReadInteger(Section, 'FormBottom', Value.Bottom);
  Ini.Free;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -