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

📄 umyreg.pas

📁 Delphi编写的一个支持语法高亮显示和很多语言的文本编辑器
💻 PAS
字号:
{
  syn
  Copyright (C) 2000-2002, Ascher Stefan. All rights reserved.
  stievie@utanet.at, http://web.utanet.at/ascherst/

  The contents of this file are subject to the Mozilla Public License
  Version 1.1 (the "License"); you may not use this file except in compliance
  with the License. You may obtain a copy of the License at
  http://www.mozilla.org/MPL/

  Software distributed under the License is distributed on an "AS IS" basis,
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  the specific language governing rights and limitations under the License.

  The Original Code is uMyReg.pas, released Sun, 26 May 2002 10:02:55 UTC.

  The Initial Developer of the Original Code is Ascher Stefan.
  Portions created by Ascher Stefan are Copyright (C) 2000-2002 Ascher Stefan.
  All Rights Reserved.

  Contributor(s): .

  Alternatively, the contents of this file may be used under the terms of the
  GNU General Public License Version 2 or later (the "GPL"), in which case
  the provisions of the GPL are applicable instead of those above.
  If you wish to allow use of your version of this file only under the terms
  of the GPL and not to allow others to use your version of this file
  under the MPL, indicate your decision by deleting the provisions above and
  replace them with the notice and other provisions required by the GPL.
  If you do not delete the provisions above, a recipient may use your version
  of this file under either the MPL or the GPL.

  You may retrieve the latest version of this file at the syn home page,
  located at http://syn.sourceforge.net/

  $Id: uMyReg.pas,v 1.2 2002/07/21 16:05:34 stievie Exp $
}

unit uMyReg;

interface

uses
  Windows, SysUtils, Classes, Registry;

type
  TMyReg = class(TRegistry)
  public
    function ReadReg(const Name: string; const Default: boolean = false): boolean; overload;
    function ReadReg(const Name: string; const Default: integer = 0): integer; overload;
    function ReadRegDouble(const Name: string; const Default: double = 0): double;
    function ReadReg(const Name: string; const Default: string = ''): string; overload;
    procedure WriteReg(const Name: string; const Value: boolean); overload;
    procedure WriteReg(const Name: string; const Value: integer); overload;
    procedure WriteReg(const Name: string; const Value: string); overload;
    function GetProgramAssociation (Ext : string) : string;

  end;

implementation

function TMyReg.ReadReg(const Name: string; const Default: boolean = false): boolean;
begin
  if ValueExists(Name) then
    result := ReadBool(Name)
  else
    result := Default;
end;

function TMyReg.ReadReg(const Name: string; const Default: integer = 0): integer;
begin
  if ValueExists(Name) then
    result := ReadInteger(Name)
  else
    result := Default;
end;

function TMyReg.ReadRegDouble(const Name: string; const Default: double = 0): double;
begin
  if ValueExists(Name) then
    result := ReadFloat(Name)
  else
    result := Default;
end;

function TMyReg.ReadReg(const Name: string; const Default: string = ''): string;
begin
  if ValueExists(Name) then
    result := ReadString(Name)
  else
    result := Default;
end;

procedure TMyReg.WriteReg(const Name: string; const Value: boolean);
begin
  WriteBool(name, value);
end;

procedure TMyReg.WriteReg(const Name: string; const Value: integer);
begin
  WriteInteger(name, value);
end;

procedure TMyReg.WriteReg(const Name: string; const Value: string);
begin
  WriteString(name, value);
end;

function TMyReg.GetProgramAssociation (Ext : string) : string;
var

 reg: TRegistry;
 s : string;
begin
 s := '';
 reg := TRegistry.Create;
 reg.RootKey := HKEY_CLASSES_ROOT;
 if reg.OpenKey('.' + ext + '\shell\open\command',
                false) <> false then begin
 {The open command has been found}
   s := reg.ReadString('');
   reg.CloseKey;
 end else begin
 {perhaps thier is a system file pointer}
   if reg.OpenKey('.' + ext,
                  false) <> false then begin
     s := reg.ReadString('');
     reg.CloseKey;
     if s <> '' then begin
    {A system file pointer was found}
       if reg.OpenKey(s + '\shell\open\command',
                      false) <> false then
    {The open command has been found}
         s := reg.ReadString('');
       reg.CloseKey;
     end;
   end;
 end;
{Delete any command line, quotes and spaces}
 if Pos('%', s) > 0 then
   Delete(s, Pos('%', s), length(s));
 if ((length(s) > 0) and
     (s[1] = '"')) then
   Delete(s, 1, 1);
 if ((length(s) > 0) and
     (pos('"', s) > 0)) then
   Delete(s, pos('"', s), Length(s));
 while ((length(s) > 0) and
        (s[length(s)] = #32)) do
   Delete(s, Length(s), 1);
 result := s;
end;

end.

⌨️ 快捷键说明

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