📄 myconst.pas
字号:
unit MyConst;
interface
const
ProjectFile = 'program %PrjName;' + #13#10 +
'uses' + #13#10 +
'SvcMgr,' + #13#10 +
'%ServerUnit in ''%ServerUnit.pas'' ,' + #13#10 +
'%SvrManagerUnit in ''%SvrManagerUnit.pas'';' + #13#10 +
'{$R *.RES}' + #13#10 +
'begin' + #13#10 +
' Application.Initialize;' + #13#10 +
' Application.CreateForm(%SvrClassName, %SvrObjectName);' + #13#10 +
' Application.Run;' + #13#10 +
'end.';
ServerUnitFile = 'unit %ServerUnit;' + #13#10 +
'' + #13#10 +
'interface' + #13#10 +
'' + #13#10 +
'uses' + #13#10 +
'Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs,' + #13#10
+
'%SvrManagerUnit;' + #13#10 +
'' + #13#10 +
'type' + #13#10 +
'%SvrClassName = class(TService)' + #13#10 +
' procedure ServiceStart(Sender: TService; var Started: Boolean);' + #13#10
+
' procedure ServiceStop(Sender: TService; var Stopped: Boolean);' + #13#10
+
'private' + #13#10 +
' MgrThread : %SvrManagerClassName;' + #13#10 +
'public' + #13#10 +
' function GetServiceController: TServiceController; override;' + #13#10 +
'end;' + #13#10 +
'' + #13#10 +
'var' + #13#10 +
'%SvrObjectName: %SvrClassName;' + #13#10 +
'' + #13#10 +
'implementation' + #13#10 +
'' + #13#10 +
'{$R *.DFM}' + #13#10 +
'' + #13#10 +
'procedure ServiceController(CtrlCode: DWord); stdcall;' + #13#10 +
'begin' + #13#10 +
' %SvrObjectName.Controller(CtrlCode);' + #13#10 +
'end;' + #13#10 +
'' + #13#10 +
'function %SvrClassName.GetServiceController: TServiceController;' + #13#10
+
'begin' + #13#10 +
' Result := ServiceController;' + #13#10 +
'end;' + #13#10 +
'' + #13#10 +
'procedure %SvrClassName.ServiceStart(Sender: TService; var Started: Boolean);' + #13#10
+
'begin' + #13#10 +
' MgrThread := %SvrManagerClassName.Create(False);' + #13#10 +
'end;' + #13#10 +
'' + #13#10 +
'procedure %SvrClassName.ServiceStop(Sender: TService; var Stopped: Boolean);' + #13#10
+
'begin' + #13#10 +
' PostThreadMessage(MgrThread.ThreadID, WM_QUIT, 0,0);' + #13#10 +
' MgrThread.WaitFor;' + #13#10 +
' MgrThread.Free;' + #13#10 +
' MgrThread:= nil;' + #13#10 +
'end;' + #13#10 +
'' + #13#10 +
'end.';
ServerFormFile = 'object %SvrObjectName: %SvrClassName' + #13#10 +
' OldCreateOrder = False' + #13#10 +
' DisplayName = '' %SvrDisplayName ''' + #13#10 +
' OnStart = ServiceStart' + #13#10 +
' OnStop = ServiceStop' + #13#10 +
' Left = 192' + #13#10 +
' Top = 103' + #13#10 +
' Height = 150' + #13#10 +
' Width = 215' + #13#10 +
'end';
ServerManagerUnitFile =
'unit %SvrManagerUnit;' + #13#10 +
'' + #13#10 +
'interface' + #13#10 +
'' + #13#10 +
'uses' + #13#10 +
' Classes, ExtCtrls, Controls, SysUtils, Windows, Messages;' + #13#10 +
'type' + #13#10 +
' %SvrManagerClassName = class(TThread)' + #13#10 +
' private' + #13#10 +
' procedure ThreadStart;' + #13#10 +
' procedure ThreadStop;' + #13#10 +
' protected' + #13#10 +
' procedure Execute; override;' + #13#10 +
' end;' + #13#10 +
'' + #13#10 +
'implementation' + #13#10 +
'' + #13#10 +
'procedure %SvrManagerClassName.ThreadStart;' + #13#10 +
'begin' + #13#10 +
' //TODO: ' + #13#10 +
'end;' + #13#10 +
'' + #13#10 +
'procedure %SvrManagerClassName.ThreadStop;' + #13#10 +
'begin' + #13#10 +
' //TODO:' + #13#10 +
'end;' + #13#10 +
'' + #13#10 +
'procedure %SvrManagerClassName.Execute;' + #13#10 +
'var' + #13#10 +
' MsgRec : TMsg;' + #13#10 +
'begin' + #13#10 +
' ThreadStart;' + #13#10 +
' while GetMessage(MsgRec, 0, 0, 0) do' + #13#10 +
' begin' + #13#10 +
' TranslateMessage(MsgRec);' + #13#10 +
' DispatchMessage(MsgRec);' + #13#10 +
' end;' + #13#10 +
' ThreadStop;' + #13#10 +
'end;' + #13#10 +
'' + #13#10 +
'end.';
FormTestProjectFile = 'program %FormTestPrjName;' + #13#10 +
'' + #13#10 +
'uses' + #13#10 +
' Forms,' + #13#10 +
' main in ''main.pas'' {Form1},' + #13#10 +
' %SvrManagerUnit in ''..\%SvrManagerUnit.pas'';' + #13#10 +
'' + #13#10 +
'{$R *.res}' + #13#10 +
'' + #13#10 +
'begin' + #13#10 +
' Application.Initialize;' + #13#10 +
' Application.CreateForm(TForm1, Form1);' + #13#10 +
' Application.Run;' + #13#10 +
'end.';
FormTestUnitFile = 'unit main;' + #13#10 +
'' + #13#10 +
'interface' + #13#10 +
'' + #13#10 +
'uses' + #13#10 +
' Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,' + #13#10
+
' Dialogs, %SvrManagerUnit;' + #13#10 +
'' + #13#10 +
'type' + #13#10 +
' TForm1 = class(TForm)' + #13#10 +
' procedure FormShow(Sender: TObject);' + #13#10 +
' procedure FormClose(Sender: TObject; var Action: TCloseAction);' + #13#10
+
' private' + #13#10 +
' MgrThread:%SvrManagerClassName;' + #13#10 +
' public' + #13#10 +
' { Public declarations }' + #13#10 +
' end;' + #13#10 +
'' + #13#10 +
'var' + #13#10 +
' Form1: TForm1;' + #13#10 +
'' + #13#10 +
'implementation' + #13#10 +
'' + #13#10 +
'{$R *.dfm}' + #13#10 +
'' + #13#10 +
'procedure TForm1.FormShow(Sender: TObject);' + #13#10 +
'begin' + #13#10 +
' MgrThread := %SvrManagerClassName.Create(False);' + #13#10 +
'end;' + #13#10 +
'' + #13#10 +
'procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);' + #13#10
+
'begin' + #13#10 +
' PostThreadMessage(MgrThread.ThreadID, WM_QUIT, 0,0);' + #13#10 +
' MgrThread.WaitFor;' + #13#10 +
' MgrThread.Free;' + #13#10 +
' MgrThread:= nil;' + #13#10 +
'end;' + #13#10 +
'' + #13#10 +
'end.';
FormTestFormFile = 'object Form1: TForm1' + #13#10 +
' Left = 192' + #13#10 +
' Top = 107' + #13#10 +
' Width = 696' + #13#10 +
' Height = 480' + #13#10 +
' Caption = '' Form1 ''' + #13#10 +
' Color = clBtnFace' + #13#10 +
' Font.Charset = DEFAULT_CHARSET' + #13#10 +
' Font.Color = clWindowText' + #13#10 +
' Font.Height = -11' + #13#10 +
' Font.Name = '' MS Sans Serif ''' + #13#10 +
' Font.Style = []' + #13#10 +
' OldCreateOrder = False' + #13#10 +
' OnClose = FormClose' + #13#10 +
' OnShow = FormShow' + #13#10 +
' PixelsPerInch = 96' + #13#10 +
' TextHeight = 13' + #13#10 +
'end';
implementation
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -