如何才能在应用程序中控制Win2000后台服务程序呢(在线等待)?

l_clove 2002-12-23 08:59:19
如题。
...全文
157 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
猛禽 2002-12-27
  • 打赏
  • 举报
回复
>多问一句,Service Application中能不能Show出一个Form?

当然可以,你看看Borland Socket Server的源码就知道了
l_clove 2002-12-26
  • 打赏
  • 举报
回复
多问一句,Service Application中能不能Show出一个Form?
l_clove 2002-12-26
  • 打赏
  • 举报
回复
好啊,这个问题困扰我很久了
warton 2002-12-26
  • 打赏
  • 举报
回复
楼上为何不在些说明些??好上大家都清楚嘛!!
说的好了加入faq!!!
warton 2002-12-26
  • 打赏
  • 举报
回复
看了!!不错!!
猛禽 2002-12-26
  • 打赏
  • 举报
回复
这是我以前用DELPHI写的:

// 操纵 Windows NT/2000 的服务
Function TMainForm.ServiceControl(aServiceName: String; aOp: Integer) : Boolean;
Var
scm : Cardinal;
svc : Cardinal;
sts : _SERVICE_STATUS;
arg : PChar;
begin
Result := true;
If ( ( GetVersion AND $80000000 ) = 0 ) Then // Is NT/2000
Begin
scm := OpenSCManager( Nil, Nil, SC_MANAGER_CONNECT );
svc := OpenService( scm, PChar( aServiceName ), SERVICE_ALL_ACCESS );
If ( svc <> 0 ) Then
Begin
QueryServiceStatus( svc, sts );
If ( ( ( aOp = 0 ) AND ( sts.dwCurrentState <> SERVICE_STOPPED ) )
OR ( ( aOp = 1 ) AND ( sts.dwCurrentState <> SERVICE_RUNNING ) ) ) Then
Begin
arg := Nil;
If ( aOp = 0 ) Then // Stop
Result := ControlService( svc, SERVICE_CONTROL_STOP, sts )
Else
Result := StartService( svc, 0, arg );
End;
CloseServiceHandle( svc );
End;
CloseServiceHandle( scm );
End;
end;
l_clove 2002-12-25
  • 打赏
  • 举报
回复
100分,up
猛禽 2002-12-25
  • 打赏
  • 举报
回复
呵,这不是很简单的事嘛,几个API,回头我找到代码发一个给你
lifehxh 2002-12-23
  • 打赏
  • 举报
回复
程序的运行状态在windows里面当他运行的时候就有它运行的ID标致,你不紧可以打开它还可以关闭它呢用FindWindow函数找出它再用SendMessage函数来关闭它;
如果你想要其它的控制也是可以的了用API吧
l_clove 2002-12-23
  • 打赏
  • 举报
回复
就是用BCB写的Win2000后台服务进程,Service Application,现在我想用其它的Application来监测其运行状态,并且操纵它,不知道能不能实现?
warton 2002-12-23
  • 打赏
  • 举报
回复
不太明白你的意思,你是打算控件进程、服务,还是写系统service??
NowCan 2002-12-23
  • 打赏
  • 举报
回复
一些和Service相关的函数,比较复杂。多看看MSDN的例子。

ChangeServiceConfig Changes the configuration parameters of a service.
ChangeServiceConfig2 Changes the optional configuration parameters of a service.
CloseServiceHandle Closes the specified handle to a service control manager object or a service object.
ControlService Sends a control code to a service.
CreateService Creates a service object and adds it to the specified service control manager database.
DeleteService Marks the specified service for deletion from the service control manager database.
EnumDependentServices Retrieves the name and status of each service that depends on the specified service.
EnumServicesStatus Enumerates services in the specified service control manager database.
EnumServicesStatusEx Enumerates services in the specified service control manager database based on the specified information level.
GetServiceDisplayName Retrieves the display name of the specified service.
GetServiceKeyName Retrieves the service name of the specified service.
Handler An application-defined callback function used with the RegisterServiceCtrlHandler function.
HandlerEx An application-defined callback function used with the RegisterServiceCtrlHandlerEx function.
LockServiceDatabase Requests ownership of the service control manager database lock.
NotifyBootConfigStatus Reports the boot status to the service control manager.
OpenSCManager Establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.
OpenService Opens an existing service.
QueryServiceConfig Retrieves the configuration parameters of the specified service.
QueryServiceConfig2 Retrieves the optional configuration parameters of the specified service.
QueryServiceLockStatus Retrieves the lock status of the specified service control manager database.
QueryServiceObjectSecurity Retrieves a copy of the security descriptor associated with a service object.
QueryServiceStatus Retrieves the current status of the specified service.
QueryServiceStatusEx Retrieves the current status of the specified service based on the specified information level.
RegisterServiceCtrlHandler Register a function to handle service control requests for an application.
RegisterServiceCtrlHandlerEx Register a function to handle service control requests for an application.
ServiceMain An application-defined function that serves as the entry point for a service.
SetServiceBits Registers a service type with the service control manager and the Server service.
SetServiceObjectSecurity Sets the security descriptor of a service object.
SetServiceStatus Updates the service control manager's status information for the calling service.
StartService Starts a service.
StartServiceCtrlDispatcher Connects the main thread of a service process to the service control manager.
UnlockServiceDatabase Unlocks a service control manager database by releasing the specified lock.

1,317

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧