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);
 
相关文档:
1、保证你传递的参数要正确:C++中的char *对应PASCAL中的pchar。
2:C++中导出的函数的参数调用方式要和你DELPHI中的导入的函数参数调用方式要一致!
例如: C++的参数调用方式 对应的DELPHI的参数调用方式
_declspec ......
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 ......
引用参数:
引用参数用var关键字标示
procedure DoubleTheValue (var Value: Integer);
begin
Value := Value * 2;
end;
在这种情况下,参数既把一个值传递给过程,又把新值返回给调用过程的代码。当你执行完以下代码时:
var
X: Integer;
begin
X := 10;
DoubleTheValue (X);
x变量的值变成了20 ......
var
L,i:integer;
Ustr,str:string;
p:char;
begin
str:='123456789ABCDEFG'
L:=length(str);
for i:=1 to l do begin
p:=str[i];
str[i]:=str[l-(i-1)];
......