Delphi编写系统服务二:系统服务和桌面程序的区别
Delphi编写系统服务二:系统服务和桌面程序的区别 收藏
Windows 2000/XP/2003等支持一种叫做“系统服务程序”的进程,系统服务和桌面程序的区别是:
系统服务不用登陆系统即可运行;
系统服务是运行在System Idle Process/System/smss/winlogon/services下的,而桌面程序是运行在Explorer下的;
系统服务拥有更高的权限,系统服务拥有Sytem的权限,而桌面程序只有Administrator权限;
在Delphi中系统服务是对桌面程序进行了再一次的封装,既系统服务继承于桌面程序。因而拥有桌面程序所拥有的特性;
系统服务对桌面程序的DoHandleException做了改进,会自动把异常信息写到NT服务日志中;
普通应用程序启动只有一个线程,而服务启动至少含有三个线程。(服务含有三个线程:TServiceStartThread服务启动线程;TServiceThread服务运行线程;Application主线程,负责消息循环);
摘录代码:
procedure TServiceApplication.Run;
begin
.
.
.
StartThread := TServiceStartThread.Create(ServiceStartTable);
try
while not Forms.Application.Terminated do
Forms.Application.HandleMessage;
Forms.Application.Terminate;
if StartThread.ReturnValue <> 0 then
FEventLogger.LogMessage(SysErrorMessage(StartThread.ReturnValue));
finally
StartThread.Free;
end;
.
.
.
end;
procedure TService.DoStart;
begin
try
Status := csStartPending;
try
FServiceThread := TServiceThread.Create(Self);
 
相关文档:
unit winntService;
interface
uses
Windows,WinSvc,WinSvcEx;
function InstallService(const strServiceName,strDisplayName,strDescription,strFilename: string):Boolean;
procedure UninstallService(strServiceName:string);
implementation
function StrLCopy(Dest: PChar; const Source: PChar; MaxLen: C ......
在多CPU或多核CPU中,会随机的获得不同的序列号.这就为我们根据CPU序列号来制作注册机带来了很大的麻烦。
Windows 2000/XP允许设置进程和线程的关系。换句话说,可以控制哪个 CPU 能够运行某些线程。这称为Affinity Mask。Windows提供了设置相似性的函数SetProcessAffinityMask ,使用它可 ......
Source Code
http://www.codefans.com/CodeList/Catalog_5_CodeTime_Desc_1.html
http://www.vscodes.com/sitemap.html
http://www.itlove.net/Soft/261/
DelphiX
http://www.micrel.cz/Dx/
http://www.delphi3d.net/index.php
http://www.pascalgamedevelopment.com/
http://www.2ccc.com/article.asp?articleid ......
Delphi 数据类型列表
分类
范围
字节
备注
简单类型
序数
整数
Integer
-2147483648 .. 2147483647
4
有符号32位
Cardinal
0 .. 4294967295
4
无符号32位
Shortint
-128 .. 127
1
有符号8位
Smallint
-32768 .. 32767
2
有符号16位
Longint
-2147483648 .. 2147483647
4
有符号32位
Int64
- ......