如何遍写NT的服务,150分呈上

flylt 2000-06-01 03:43:00
我想编一NT的服务用来完成一些后台功能,用VB怎么做,需注意什么,望各位专家指教(最好有例程),150呈上
...全文
492 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
Chen_Lin 2000-06-10
  • 打赏
  • 举报
回复
rosement的解答大家可以在以下地址找到:
Http://msdn.microsoft.com/library/techart/msdn_ntsrvocx.htm
xlzhou 2000-06-09
  • 打赏
  • 举报
回复
use
srvinstw.exe -- install a application as a service program

srvany.exe -- encapsulate application to a service program

You'd better don't use VB write service, MS don't support that!

These utility could be found from NT resource kit.




茂奇软件 2000-06-09
  • 打赏
  • 举报
回复
look at codeguru
there is a famouse wizard for
create a nt service project.
good lucky.
jansen zhu.
rosement 2000-06-09
  • 打赏
  • 举报
回复
为了回答这个问题,我已经给一些网友发了必要的ACTIVEX,这里给大家一个例子:
Sub Main()
Load Form1
Dim strDisplayName As String

On Error GoTo Err_Load

strDisplayName = Form1.NTService1.DisplayName

If Command = "-install" Then
' Enable interaction with desktop.
Form1.NTService1.Interactive = True

If Form1.NTService1.Install Then
MsgBox strDisplayName & " installed successfully"
Else
MsgBox strDisplayName & " failed to install"
End If
End

ElseIf Command = "-uninstall" Then
If Form1.NTService1.Uninstall Then
MsgBox strDisplayName & " uninstalled successfully"
Else
MsgBox strDisplayName & " failed to uninstall"
End If
End

ElseIf Command = "-debug" Then
Form1.NTService1.Debug = True

ElseIf Command <> "" Then
MsgBox "Invalid command option"
End

End If

' Connect service to Windows NT services controller.
Form1.NTService1.StartService

Err_Load:
' Error starting service


End Sub

Private Sub NTService1_Start(Success As Boolean)
On Error GoTo Err_Start

' TODO: Begin processing

Success = True ' Report success

Err_Start:
Call NTService1.LogEvent(svcMessageError, svcEventError, "[" & _
Err.Number & "] " & Err.Description)

End Sub
Private Sub NTService1_Start(Success As Boolean)
On Error GoTo Err_Start

' TODO: Begin processing

Success = True ' Report success

Err_Start:
Call NTService1.LogEvent(svcMessageError, svcEventError, "[" & _
Err.Number & "] " & Err.Description)

End Sub
希望以上的例子对大家有用:
注意运行时:***.exe -install :装入服务程序(运行后打开你的控制面板,查看服务,发现了什么??!!!)
***.exe -install :卸载服务程序



flylt 2000-06-09
  • 打赏
  • 举报
回复
能详细点吗??
flylt 2000-06-08
  • 打赏
  • 举报
回复
rosement 我给你发了,怎么没回音?
rosement 2000-06-03
  • 打赏
  • 举报
回复
其实以上的论断都不对,我就作过VB的NT服务,还作过只用模块生成C的窗口类型,其实在VB中写服务的关键不在于技术,你如果单纯认为将C的代码改为VB的代码的话,那你就错了。
我这里有你需要的真正的VB/NT服务程序,及编写需要的利器,如需:EMAIL:ROSEMENT@TELEKBIRD.COM.CN,用了以后,不要不给分!!!
flylt 2000-06-02
  • 打赏
  • 举报
回复
怎么调有例子吗?
zy 2000-06-02
  • 打赏
  • 举报
回复
那你只好在vb中狂调win32 api
flylt 2000-06-02
  • 打赏
  • 举报
回复
可我想用vb做
flylt 2000-06-02
  • 打赏
  • 举报
回复
发给我!
Email:lutaochina@sina.com
hibor 2000-06-02
  • 打赏
  • 举报
回复
jing , pleae give me a copy
"hibor@sohu.com"
thanks !
jing 2000-06-02
  • 打赏
  • 举报
回复
我有一个 但用C++的你要吗
flylt 2000-06-02
  • 打赏
  • 举报
回复
wjf 能更详细点吗?
发邮件给我,OK?
wjf 2000-06-02
  • 打赏
  • 举报
回复
剩下的查MSDN就行了
wjf 2000-06-02
  • 打赏
  • 举报
回复
给你几个API;

SC_HANDLE OpenSCManager(
LPCTSTR lpMachineName, // pointer to machine name string
LPCTSTR lpDatabaseName, // pointer to database name string
DWORD dwDesiredAccess // type of access
);

SC_HANDLE CreateService(
SC_HANDLE hSCManager, // handle to service control manager
// database
LPCTSTR lpServiceName, // pointer to name of service to start
LPCTSTR lpDisplayName, // pointer to display name
DWORD dwDesiredAccess, // type of access to service
DWORD dwServiceType, // type of service
DWORD dwStartType, // when to start service
DWORD dwErrorControl, // severity if service fails to start
LPCTSTR lpBinaryPathName, // pointer to name of binary file
LPCTSTR lpLoadOrderGroup, // pointer to name of load ordering
// group
LPDWORD lpdwTagId, // pointer to variable to get tag identifier
LPCTSTR lpDependencies, // pointer to array of dependency names
LPCTSTR lpServiceStartName,
// pointer to account name of service
LPCTSTR lpPassword // pointer to password for service account
);
SC_HANDLE OpenService(
SC_HANDLE hSCManager, // handle to service control manager
// database
LPCTSTR lpServiceName, // pointer to name of service to start
DWORD dwDesiredAccess // type of access to service
);

BOOL DeleteService(
SC_HANDLE hService // handle to service
);
BOOL StartServiceCtrlDispatcher(
LPSERVICE_TABLE_ENTRY lpServiceStartTable // address of service
// table
);
BOOL SetServiceStatus(
SERVICE_STATUS_HANDLE hServiceStatus~,
// service status handle
LPSERVICE_STATUS lpServiceStatus // address of status structure
);
evelan 2000-06-01
  • 打赏
  • 举报
回复
呵呵~~~ ,我只会用VC做,转行学VC吧~~

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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