unit NTServiceList;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
WinSvc;
type PMyServices =^TMyServices;
TMyServices = array[0..255] of TEnumServiceStatus;type
TNTServiceList = class(TComponent)
private
{ Private declarations }
FServiceList : TStringlist;
FServer : string;
FSCManagerHandle : HWND;
function Display_status(status_code:DWORD):string;
function GetEnumPriv : boolean;
function GetServer : string;
function GetServiceList : tstringlist;
procedure SetServer (value : string);
procedure DoServiceList; protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override; published
{ Published declarations }
property Server : string read GetServer write SetServer;
property ServiceList : tstringlist read GetServiceList; end;procedure Register;
const
SERVICE_WIN32_OWN_PROCESS = $00000010;
SERVICE_WIN32_SHARE_PROCESS = $00000020;
SERVICE_WIN32 = (SERVICE_WIN32_OWN_PROCESS or
SERVICE_WIN32_SHARE_PROCESS);
SERVICE_ACTIVE = 1;
SERVICE_INACTIVE = 2;
SERVICE_STATE_ALL = SERVICE_ACTIVE + SERVICE_INACTIVE;
implementationconstructor TNTServiceList.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FServiceList := tstringlist.Create;
end;
让大家看了这么一大段,其实我的问题很简单,我在调用create方法生成NTServiceList这个类的实例时,create()方法中的AOwner: TComponent,我应该替换成什么呢?我不明白这个参数的含义.谢谢
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
WinSvc;
type PMyServices =^TMyServices;
TMyServices = array[0..255] of TEnumServiceStatus;type
TNTServiceList = class(TComponent)
private
{ Private declarations }
FServiceList : TStringlist;
FServer : string;
FSCManagerHandle : HWND;
function Display_status(status_code:DWORD):string;
function GetEnumPriv : boolean;
function GetServer : string;
function GetServiceList : tstringlist;
procedure SetServer (value : string);
procedure DoServiceList; protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override; published
{ Published declarations }
property Server : string read GetServer write SetServer;
property ServiceList : tstringlist read GetServiceList; end;procedure Register;
const
SERVICE_WIN32_OWN_PROCESS = $00000010;
SERVICE_WIN32_SHARE_PROCESS = $00000020;
SERVICE_WIN32 = (SERVICE_WIN32_OWN_PROCESS or
SERVICE_WIN32_SHARE_PROCESS);
SERVICE_ACTIVE = 1;
SERVICE_INACTIVE = 2;
SERVICE_STATE_ALL = SERVICE_ACTIVE + SERVICE_INACTIVE;
implementationconstructor TNTServiceList.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FServiceList := tstringlist.Create;
end;
让大家看了这么一大段,其实我的问题很简单,我在调用create方法生成NTServiceList这个类的实例时,create()方法中的AOwner: TComponent,我应该替换成什么呢?我不明白这个参数的含义.谢谢
Opendialog:TOpendialog;
begin
Opendialog:=Topendialog.create(nil); try
if Opendialog.execute then
{...}
finally
Opendialog.free;//这就是手动释放,如果你的Opendialg的Create参数为self,这里可以手动释放,也可以不手动释放,手动释放可以及时回收资源(就是程序的内存占用),手动释放未必都是free方法,需要看这个控件本身的析构方法。
end;end;