Exp=M
ModuleFileName=SoftKey.pas
mgs=ע⣺ڱܹʱҪеSoftKey.pas,yt.objӵҪܵĹڵĿ¼С
@end
                                        
unit SoftKey;
//´칤Զɣѡģ顱
interface

uses
//ע⣺ڱܹʱҪеSoftKey.pas,yt.objӵҪܵĹڵĿ¼
  Windows, SysUtils, Forms,SoftKeyPro;

//ԤϢ
const
  ErrorMessage257= 'Windows NT²ܴ򿪶˿ڣԭδװ򣬻װʧܡ룺-257';
  ErrorMessage201= 'ļڻ޷򿪼ļ룺-201';
  ErrorMessage203= '޷ȡļ룺-203';
  ErrorMessage204= '޷ȡļ룺-204';
  ErrorMessage213= 'ַܵȴ256޷תļ룺-213';
  ErrorMessage46= 'ĲΪգ룺-46';
  ErrorMessage2= 'ʧܣԭ޼汾ȷ룺-2';
  ErrorMessage92= 'ʧܣԭ޼汾ȷ룺-92';
  ErrorMessage1= '󣡷룺-1';



function GetErrorMessage(ErrorCode: integer): string;

procedure ShowKeyMessage(ErrorCode:integer);

function GetKeyLastError: integer;

//*****ʹôɵĺӿ*****
procedure Ini;

procedure Ini_2(HKey: string; LKey: string);

function ReadSN(var HKey, LKey: String): Integer;

function CheckKey_1: boolean;

function YStrCat_1(S1, S2: string): string;

function YAnsiCompareText_1(S1, S2: string): integer;

function YAnsiCompareStr_1(S1, S2: string): integer;

function YStrCopy_1(S: string): string;

function YCompareVal_1(V1, V2: longint; Exp: Char): boolean;

function YSetValue_1(V: longint): longint;

function YAdd_1(V1, V2: longint): longint;

function YDecrease_1(V1, V2: longint): longint;

function YMultiply_1(V1, V2: longint): longint;

function YDivide_1(V1, V2: longint): longint;

function YAnd_1(V1, V2: boolean): boolean;

function YOr_1(V1, V2: boolean): boolean;

implementation

var
  KeyPath: string= '';  //ñڱڵ·ԱCal_2ĵ
  KeyLastError: integer= 0;  //ñڱһβ
  E_HKey, E_LKey: String;



//*****ΪһЩúʵ*****
//ӼжȡӦȨ
function ReadSN(var HKey, LKey: String): Integer;
var
  i: Integer;
  aByte: Byte;
begin
  HKey:= '';
  LKey:= '';
  for i:= 0 to 3 do
    begin
    Result:= YReadEx(i, @aByte,  PChar(KeyPath));
    if Result <> 0 then
      Exit;
    HKey:= IntToHex(aByte, 2) + HKey;
    end;
  for i:= 4 to 7 do
    begin
    Result:= YReadEx(i, @aByte,  PChar(KeyPath));
    if Result <> 0 then
      Exit;
    LKey:= IntToHex(aByte, 2) + LKey;
    end;
end;

//ݼķ룬شĺ
function GetErrorMessage(ErrorCode: integer): string;
begin
  case ErrorCode of
   -257: Result:= ErrorMessage257;
   -201: Result:= ErrorMessage201;
   -203: Result:= ErrorMessage203;
   -204: Result:= ErrorMessage204;
   -213: Result:= ErrorMessage213;
    -46: Result:= ErrorMessage46;
    -92: Result:= ErrorMessage92;
     -2: Result:= ErrorMessage2;
     -1: Result:= ErrorMessage1;
  else
    Result:= 'ʱϵ룺'+ IntToStr(ErrorCode);
  end;
end;

//GetKeyLastErrorʱúʾĴϢʾ
procedure ShowKeyMessage(ErrorCode:integer);
begin
  Application.MessageBox(PChar(GetErrorMessage(ErrorCode)), '', 48);
end;

//ȡһβķ룬úزʱ
//GetErrorMessage(ErrorCode: integer): string;ɻô뺬壬
//ShowKeyMessage(ErrorCode:integer);ʾĴϢʾ
function GetKeyLastError: integer;
begin
  Result:= KeyLastError;
end;


//*****Ϊܺʵ*****
#Ini#

#ini_2#

#CheckKey#

#YStrCat#

#YAnsiCompareText#

#YAnsiCompareStr#

#YStrCopy#

#YCompareVal#

#YSetValue#

#YAdd#

#YDecrease#

#YMultiply#

#YDivide#

#YAnd#

#YOr#

end.