berlinpie.dpr

来自「Delphi实效编程百例的随书源代码 这是其中的操作系统部分」· DPR 代码 · 共 83 行

DPR
83
字号
PROGRAM BerlinPie;
{$D SCRNSAVE BerlinPie}

uses
  MMSystem,
  Classes,
  Controls,
  SysUtils,
  Windows,
  Messages,
  Graphics,
  Forms,
  UPie,
  Config in 'CONFIG.PAS' {DialogConfig},
  Globals in 'Globals.pas',
  UBerlinSCR in 'UBerlinSCR.pas' {FormSpecSCR};

{$R *.RES}
{$E SCR}		// Extension
{$R StrTable.RES}	// In dieser Datei steht der in der Systemsteuerung angezeigte Name
{$R Sounds.RES}		// die Kl鋘ge

VAR
  hSemaphore		: THandle;
  sstrArg1, sstrArg2	: SHORTString;
  hMod   		: THandle;
  strSysDir      	: String;
  iNewLen      		: Integer;
  functionPwd  		: function (a : PChar; ParentHandle : THandle; b, c : Integer): Integer; stdcall;
  hPrevWnd		: HWnd;
  aRect			: TRect;
  iScrWidth, iScrHeight : Integer;
  aCanvas    		: TCanvas;
  aRegEntries		: TBerlinUhrRegEntries;
  aSettings		: TBerlinUhrColors;
  aBerlinUhr		: TBerlinUhr;

(*++++++++++++++++++++++++++++++++++*)
BEGIN
hSemaphore := CreateSemaphore( nil, 0, 1, 'BerlinPieSCRSemaphore' );
IF ((hSemaphore <> 0) and (GetLastError = ERROR_ALREADY_EXISTS)) THEN
  BEGIN
  AppendText(' halted (ERROR_ALREADY_EXISTS)' );
  CloseHandle(hSemaphore);
  Halt;
  END;

sstrArg1 := UpperCase(ParamStr(1));
sstrArg2 := UpperCase(ParamStr(2));

IF (Copy(sstrArg1,1,2) = '/A') OR (Copy(sstrArg1,1,2) = '-A') OR
   (Copy(sstrArg1,1,1) = 'A') THEN
  aSSMode := ssSetPwd;

IF (Copy(sstrArg1,1,2) = '/P') OR (Copy(sstrArg1,1,2) = '-P') OR
   (Copy(sstrArg1,1,1) = 'P') THEN
  aSSMode := ssPreview;

IF (Copy(sstrArg1,1,2) = '/C') OR (Copy(sstrArg1,1,2) = '-C') OR
   (Copy(sstrArg1,1,1) = 'C') OR (sstrArg1 = '') THEN
  aSSMode := ssConfig;

IF aSSMode = ssSetPwd THEN
  BEGIN
  SetLength(strSysDir,MAX_PATH);
  iNewLen := GetSystemDirectory(PChar(strSysDir),MAX_PATH);
  SetLength( strSysDir, iNewLen);
  IF (Length( strSysDir ) > 0) and (strSysDir[Length(strSysDir)] <> '\') THEN
    strSysDir := strSysDir+'\';
  hMod := LoadLibrary(PChar(strSysDir+'MPR.DLL'));
  IF hMod <> 0 THEN
    BEGIN
    functionPwd := GetProcAddress( hMod,'PwdChangePasswordA');
    IF Assigned( functionPwd ) THEN
      functionPwd('SCRSAVE',StrToInt(sstrArg2),0,0);
    FreeLibrary(hMod);
    END;
  AppendText(' halted (ssSetPWD)' );
  Halt;
  END;

Application.Initialize;
Application.Title := 'BerlinPieSCR - 

⌨️ 快捷键说明

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