如何编servU组件阿?[1000分]

zcm123 2004-08-13 05:34:22
修改ini已经完成了 可servu就是不刷新信息! 我用vb编的组建 郁闷阿!

如何编servu组件阿! 高分请教 1000分
...全文
260 点赞 收藏 35
写回复
35 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
mrshelly 2004-08-20
嘿嘿,我一大早来就看到这个.还不早啊????
哈哈哈~~~~~~~~~~~
回复
someeyes 2004-08-20
我原来又不知道,有这个方法!上面的代码是重起服务的!知道了这个方法还是今天早上!你早知道,不早来回答!等我解决完了,在我楼下说风凉话!
回复
mrshelly 2004-08-20
9494
楼上讲那么多, 最关键的一点就是这个
ReloadSettings=1

http://www.blogbus.com/blogbus/blog/diary.php?diaryid=131680

我被楼上的N长程序看晕了~~~~~~~~~~

回答问题 抓关键点就成了。
动不动就一长篇代码,看的人头大~~~~~~~~~~~~~~~~
回复
someeyes 2004-08-20
我又找到了新的解决方法,不用重起服务了!你得履行诺言,给我分啊!
修改完.ini文件后在[GLOBAL]里加入一条ReloadSettings=True就都搞定了!
你要不履行诺言,可没有下回了!
回复
someeyes 2004-08-19
Shell "net stop serv-u", vbHide
Shell "net start serv-u", vbHide
这个方法可能由于第一条执行太慢而第二条执行无效,可以在两条中间加一个检查服务运行是否结束,如果以结束在执行第二条!或者干脆在两者中间加个延时!但还是第一个好!检查服务运行是否结束这个我已经实现,目前正在提炼代码!有时间发给你!
回复
zcm123 2004-08-19
up
回复
someeyes 2004-08-19

Public Enum e_ServiceType
e_ServiceType_Disabled = 4
e_ServiceType_Manual = 3
e_ServiceType_Automatic = 2
e_ServiceType_SystemStart = 1
e_ServiceType_BootTime = 0
End Enum

Private Const SERVICE_ERROR_NORMAL As Long = &H1

Public Enum e_ServiceControl
e_ServiceControl_Stop = &H1
e_ServiceControl_Pause = &H2
e_ServiceControl_Continue = &H3
e_ServiceControl_Interrogate = &H4
e_ServiceControl_Shutdown = &H5
End Enum

Public Enum e_ServiceState
e_ServiceState_Stopped = &H1
e_ServiceState_StartPending = &H2
e_ServiceState_StopPending = &H3
e_ServiceState_Running = &H4
e_ServiceState_ContinuePending = &H5
e_ServiceState_PausePending = &H6
e_ServiceState_Paused = &H7
End Enum

Private Type SERVICE_TABLE_ENTRY
lpServiceName As String
lpServiceProc As Long
lpServiceNameNull As Long
lpServiceProcNull As Long
End Type

Private Type SERVICE_STATUS
dwServiceType As Long
dwCurrentState As Long
dwControlsAccepted As Long
dwWin32ExitCode As Long
dwServiceSpecificExitCode As Long
dwCheckPoint As Long
dwWaitHint As Long
End Type

Private Type QUERY_SERVICE_CONFIG
dwServiceType As Long
dwStartType As Long
dwErrorControl As Long
lpBinaryPathName As Long 'String
lpLoadOrderGroup As Long ' String
dwTagId As Long
lpDependencies As Long 'String
lpServiceStartName As Long 'String
lpDisplayName As Long 'String
End Type

Private Declare Function QueryServiceConfig Lib "advapi32.dll" Alias "QueryServiceConfigA" (ByVal hService As Long, lpServiceConfig As Byte, ByVal cbBufSize As Long, pcbBytesNeeded As Long) As Long
Private Declare Function QueryServiceStatus Lib "advapi32.dll" (ByVal hService As Long, lpServiceStatus As SERVICE_STATUS) As Long
Private Declare Function OpenSCManager Lib "advapi32.dll" Alias "OpenSCManagerA" (ByVal lpMachineName As String, ByVal lpDatabaseName As String, ByVal dwDesiredAccess As Long) As Long
Declare Function OpenService Lib "advapi32.dll" Alias "OpenServiceA" (ByVal hSCManager As Long, ByVal lpServiceName As String, ByVal dwDesiredAccess As Long) As Long

Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function lstrcpy Lib "KERNEL32" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As Long) As Long

Declare Function CloseServiceHandle Lib "advapi32.dll" (ByVal hSCObject As Long) As Long

Public Function CheckServiceRunning(ByVal serviceName As String, Optional ByRef serviceRunning As e_ServiceState, Optional ByRef serviceStartType As e_ServiceType, Optional servicePath As String) As Boolean
Dim hSCM As Long
Dim hSVC As Long
Dim pSTATUS As SERVICE_STATUS
Dim udtConfig As QUERY_SERVICE_CONFIG
Dim lRet As Long
Dim lBytesNeeded As Long
Dim sTemp As String
Dim pFileName As Long

CheckServiceRunning = True
' Open The Service Control Manager
'
hSCM = OpenSCManager(vbNullString, vbNullString, SC_MANAGER_CONNECT)
If hSCM = 0 Then
CheckServiceRunning = False
End If

' Open the specific Service to obtain a handle
'
hSVC = OpenService(hSCM, Trim(serviceName), GENERIC_READ)
If hSVC = 0 Then
CheckServiceRunning = False
'MsgBox "Error - " & Err.LastDllError
GoTo CloseHandles
End If

' Fill the Service Status Structure
'
lRet = QueryServiceStatus(hSVC, pSTATUS)
If lRet = 0 Then
CheckServiceRunning = False
GoTo CloseHandles
End If

' Report the Current State
'
Select Case pSTATUS.dwCurrentState
Case SERVICE_STOP
serviceRunning = e_ServiceState_Stopped
Case SERVICE_START
serviceRunning = e_ServiceState_StartPending
Case SERVICE_STOP_PENDING
serviceRunning = e_ServiceState_StopPending
Case SERVICE_RUNNING
serviceRunning = e_ServiceState_Running
Case SERVICE_CONTINUE_PENDING
serviceRunning = e_ServiceState_ContinuePending
Case SERVICE_PAUSE_PENDING
serviceRunning = e_ServiceState_PausePending
Case SERVICE_PAUSED
serviceRunning = e_ServiceState_Paused
Case SERVICE_ACCEPT_STOP
serviceRunning = e_ServiceState_Stopped
Case SERVICE_ACCEPT_PAUSE_CONTINUE
serviceRunning = e_ServiceState_Paused
Case SERVICE_ACCEPT_SHUTDOWN
serviceRunning = e_ServiceState_StopPending
End Select

' Call QueryServiceConfig with 1 byte buffer to generate an error
' that returns the size of a buffer we need.
'
ReDim abConfig(0) As Byte
lRet = QueryServiceConfig(hSVC, abConfig(0), 0&, lBytesNeeded)
If lRet = 0 And Err.LastDllError <> ERROR_INSUFFICIENT_BUFFER Then
CheckServiceRunning = False
End If

' Redim our byte array to the size necessary and call
' QueryServiceConfig again
'
ReDim abConfig(lBytesNeeded) As Byte
lRet = QueryServiceConfig(hSVC, abConfig(0), lBytesNeeded, _
lBytesNeeded)
If lRet = 0 Then
CheckServiceRunning = False
GoTo CloseHandles
End If

' Fill our Service Config User Defined Type.
'
CopyMemory udtConfig, abConfig(0), Len(udtConfig)

serviceStartType = udtConfig.dwStartType

sTemp = Space(255)

' Now use the pointer obtained to copy the path into the temporary
' String Variable
'
lRet = lstrcpy(sTemp, udtConfig.lpBinaryPathName)
servicePath = Trim(sTemp)

CloseHandles:
' Close the Handle to the Service
'
CloseServiceHandle (hSVC)

' Close the Handle to the Service Control Manager
'
CloseServiceHandle (hSCM)
End Function

'重启Serv-U服务,使改动生效
Public Sub ReStartServer()
Dim serviceRunning As e_ServiceState
Shell "net stop serv-u", vbHide
Do
If CheckServiceRunning("serv-u", serviceRunning) = True Then
If serviceRunning = e_ServiceState_Stopped Then
Shell "net start serv-u", vbHide
Exit Do
End If
End If
DoEvents
Loop
'Ru = RunService("serv-u")
End Sub
回复
someeyes 2004-08-19
修改ini的我就不发了,把我整理的重启ServU的代码给你发上去!
Private Const SERVICE_WIN32_OWN_PROCESS = &H10&
Private Const SERVICE_WIN32_SHARE_PROCESS = &H20&
Private Const SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS + SERVICE_WIN32_SHARE_PROCESS

Private Const SC_MANAGER_CONNECT = &H1
Private Const SC_MANAGER_CREATE_SERVICE = &H2
Private Const SC_MANAGER_ENUMERATE_SERVICE = &H4
Private Const SC_MANAGER_LOCK = &H8
Private Const SC_MANAGER_QUERY_LOCK_STATUS = &H10
Private Const SC_MANAGER_MODIFY_BOOT_CONFIG = &H20

Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const SERVICE_QUERY_CONFIG = &H1
Private Const SERVICE_CHANGE_CONFIG = &H2
Private Const SERVICE_QUERY_STATUS = &H4
Private Const SERVICE_ENUMERATE_DEPENDENTS = &H8
Private Const SERVICE_START = &H10
Private Const SERVICE_STOP = &H20
Private Const SERVICE_PAUSE_CONTINUE = &H40
Private Const SERVICE_INTERROGATE = &H80
Private Const SERVICE_USER_DEFINED_CONTROL = &H100
Private Const SERVICE_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SERVICE_QUERY_CONFIG Or SERVICE_CHANGE_CONFIG Or SERVICE_QUERY_STATUS Or SERVICE_ENUMERATE_DEPENDENTS Or SERVICE_START Or SERVICE_STOP Or SERVICE_PAUSE_CONTINUE Or SERVICE_INTERROGATE Or SERVICE_USER_DEFINED_CONTROL)

Private Const SERVICE_CONTROL_CONTINUE = &H3
Private Const SERVICE_CONTROL_INTERROGATE = &H4
Private Const SERVICE_CONTROL_PAUSE = &H2
Private Const SERVICE_CONTROL_SHUTDOWN = &H5
Private Const SERVICE_CONTROL_STOP = &H1

Private Const SERVICE_STOPPED = &H1
Private Const SERVICE_START_PENDING = &H2
Private Const SERVICE_STOP_PENDING = &H3
Private Const SERVICE_RUNNING = &H4
Private Const SERVICE_CONTINUE_PENDING = &H5
Private Const SERVICE_PAUSE_PENDING = &H6
Private Const SERVICE_PAUSED = &H7
Private Const SERVICE_ACCEPT_STOP = &H1
Private Const SERVICE_ACCEPT_PAUSE_CONTINUE = &H2
Private Const SERVICE_ACCEPT_SHUTDOWN = &H4

Private Const SERVICE_DISABLED As Long = &H4
Private Const SERVICE_DEMAND_START As Long = &H3
Private Const SERVICE_AUTO_START As Long = &H2
Private Const SERVICE_SYSTEM_START As Long = &H1
Private Const SERVICE_BOOT_START As Long = &H0

Private Const GENERIC_READ = &H80000000
Private Const ERROR_INSUFFICIENT_BUFFER = 122

回复
BlackBabbitt 2004-08-18
高深,不懂~~
回复
someeyes 2004-08-18
我有办法!但不知道是不是得不常失!
Shell "net stop serv-u", vbHide
Shell "net start serv-u", vbHide
回复
凯晰叶子 2004-08-16
实在不好意思!因为工作,所都不管这么多就把MD5也给粘上了!

占了你这么多空间!深感抱歉!
回复
lang11zi 2004-08-16
创建ASP组件修改《SERV-U》FTP 的密码


新建一《SERV-U》FTP服务器,在ASP中修改指定帐户的密码,写了一ASP组件来修改《SERV—U》 FTP密码。
启动《Vb6.0》,选择新建ActiveX DLL,更改工程属性中的工程名称为“Ftpcommand”,将CLASS名改为XJNFTP,源程序如下:

Private Const scUserAgent = "vb wininet"
Private Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Private Const INTERNET_OPEN_TYPE_DIRECT = 1
Private Const INTERNET_OPEN_TYPE_PROXY = 3
Private Const INTERNET_INVALID_PORT_NUMBER = 0
Private Const FTP_TRANSFER_TYPE_BINARY = &H2
Private Const FTP_TRANSFER_TYPE_ASCII = &H1
Private Const INTERNET_FLAG_PASSIVE = &H8000000
Private Const INTERNET_SERVICE_FTP = 1
Private Const INTERNET_SERVICE_GOPHER = 2
Private Const INTERNET_SERVICE_HTTP = 3
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function FtpCommand Lib "wininet.dll" Alias "FtpCommandA" _
(ByVal hConnect As Long, ByVal fExpectResponse As Boolean, ByVal dwFlags As Long, _
ByVal lpszCommand As String, ByVal lContext As Long, phFtpCommand As Long) As Boolean
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _
(ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, _
ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, _
ByVal lFlags As Long, ByVal lContext As Long) As Long
Private hOpen As Long
Private hConnection As Long
Private Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInet As Long) As Integer
Private newPASSWORD As String
Private oldPASSWORD As String
Private userName As String
Private URLSTR As String


‘修改FTP密码主程序
Public Function getStr() As String
hOpen = 0
hConnection = 0
Dim nFlag As Long
Dim strCmd As String
nFlag = INTERNET_FLAG_PASSIVE
‘建立FTP修改密码命令字符串
strCmd = "SITE PSWD " & oldPASSWORD & Space(1) & newPASSWORD
‘建立internet连接
hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
If hOpen = 0 Then getStr = "不能打开连接。..."
If hOpen <> 0 Then
‘与FTP服务器建立连接
hConnection = InternetConnect(hOpen, URLSTR, NTERNET_INVALID_PORT_NUMBER, _
userName, oldPASSWORD, INTERNET_SERVICE_FTP, nFlag, 0)
If hConnection <> 0 Then
bret = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_ASCII, strCmd, 0, hFile)
If bret Then
getStr = "密码修改成功!..."
Else
getStr = "密码修改失败!..."
End If
Else
getStr = "无法登录至FTP服务器,请检查帐户名或密码是否正确。"
End If
End If
‘断开internet连接
If hConnection <> 0 Then InternetCloseHandle (hConnection)
‘断开FTP服务器连接
If hOpen <> 0 Then InternetCloseHandle (hOpen)
End Function
‘传入FTP服务器的URL
Public Property Let URL(URL1 As String)
URLSTR = URL1
End Property

‘传入FTP原有密码
Public Property Let oldPSD(psd As String)
oldPASSWORD = psd
End Property

‘传入FTP新密码
Public Property Let newPSD(psd1 As String)
newPASSWORD = psd1
End Property

‘传入FTP帐户名
Public Property Let user(psd2 As String)
userName = psd2
End Property

编译成Ftpcommand.DLL,在ASP服务器端注册该组件,(VB6.0在ASP服务器中自动注册),在ASP中调用该组件,源程序如下:
<%
‘接受传入的帐户名
user=trim(request.form("id"))
‘接受传入的原密码
psw=trim(request.form("password"))
‘接受传入的新密码
pswx=trim(request.form("passwordx"))
‘创建FTP组件应用实例
Dim obj
Set obj = Server.CreateObject("ftpcommand.xjnftp")
‘给FTP组件传送帐户名
obj.user=user
‘给FTP组件传送原密码
obj.oldpsd=psw
‘给FTP组件传送新密码
obj.newpsd=pswx
‘给FTP组件传送FTP服务器域名地址(URL)
obj.url="ftp://ftp.luckybbs.com"
rr=obj.getstr()
Response.Write("<meta HTTP-EQUIV=REFRESH CONTENT=3;URL=/main.asp>")
Response.Write("<p><center><font color=#ff0000>"+rr+"!")
Response.Write("<center><font color=#ff0000>系统3秒钟后自动返回!!!</font></center>")
Response.Write("<br><center><a href=main.asp>返回</a></center>")
set obj=nothing
response.end
%>

本实例在WINDOWS 2000 SERVER ,IIS 5.0 ,SERV-U4.0 ,VB6.0中通过。
回复
zcm123 2004-08-16
怎么个从起阿?????????????????????????
回复
xeimm 2004-08-16
我记得改了ini以后 还要重起才行吧。
回复
gu1dai 2004-08-16
这个问题收藏
回复
zcm123 2004-08-16
up
回复
zcm123 2004-08-14
up
回复
tigerhu76 2004-08-14
我发觉用了数据库后,serv-u服务器便不能自动启动,必须手动才行。不知道有没有办法解决?
回复
zcm123 2004-08-14
分不够可以在加
回复
zcm123 2004-08-14
我又开了200分贴 希望大家能够给我解答



http://community.csdn.net/Expert/TopicView.asp?id=3273474
回复
加载更多回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-08-13 05:34
社区公告
暂无公告