Jun 8th, 2001, 03:52 AM
#1
Thread Starter
Addicted Member
is "ANYONE" any good with services
I am officialy almost stuck. lol,
Option Explicit
Public iOpenScManagerResult As Long
Public iOpenService As Long
Public iGetServiceKeyNameResult As Long
Public iLockServiceDatabaseResult As Long
Public iUnlockServiceDatabaseResult As Long
Public slpMachineName As String
Public slpDatabaseName As String
Public sServiceName As String
Public slpServiceName As String
Public srServiceName As String
Public iLenServiceName As Long
Private Sub Form_Load()
sServiceName = "Dr Solomon's Task Manager" & Null
'get service control number
iOpenScManagerResult = OpenSCManager(slpMachineName, slpDatabaseName, SC_MANAGER_ALL_ACCESS)
'lock service control database so that it can be modified
iLockServiceDatabaseResult = LockServiceDatabase(iOpenScManagerResult)
iGetServiceKeyNameResult = GetServiceKeyName(iOpenScManagerResult, sServiceName, srServiceName, iLenServiceName)
MsgBox srServiceName
iOpenService = OpenService(iOpenScManagerResult, srServiceName, SERVICE_ALL_ACCESS)
're-open service control database
iUnlockServiceDatabaseResult = UnlockServiceDatabase(iLockServiceDatabaseResult)
End Sub
Due to the energy crisis, the light at the end of the tunnel has been turned off.
Sorry for any inconvenience this may cause
Jun 8th, 2001, 05:22 AM
#2
Thread Starter
Addicted Member
the getservicekeyname isnt giving me a result, can anyone help??
Due to the energy crisis, the light at the end of the tunnel has been turned off.
Sorry for any inconvenience this may cause
Jun 8th, 2001, 05:56 AM
#3
Fanatic Member
zip up the project and i'll see what I can do, for a fellow westcountryman (OOAARRR)...
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
Jun 8th, 2001, 06:04 AM
#4
Thread Starter
Addicted Member
i got a brand new vb project, an i'll give u the bugs
Attached Files
Due to the energy crisis, the light at the end of the tunnel has been turned off.
Sorry for any inconvenience this may cause
Jun 8th, 2001, 06:21 AM
#5
Fanatic Member
you got 50 lines o' code
and I got forty three.....
Code:
Private Sub Form_Load()
srServiceName = String(256, " ")
sServiceName = "SWEEP for Windows NT" & vbNullChar
iLenServiceName = Len(sServiceName) + 1
iOpenScManagerResult = OpenSCManager(slpMachineName, slpDatabaseName, SC_MANAGER_ALL_ACCESS)
iGetServiceKeyNameResult = GetServiceKeyName(iOpenScManagerResult, sServiceName, srServiceName, iLenServiceName)
MsgBox srServiceName
iOpenService = OpenService(iOpenScManagerResult, srServiceName, SERVICE_ALL_ACCESS)
End Sub
it worked for me....
BTW Cornwaaaall
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
Jun 8th, 2001, 06:29 AM
#6
Thread Starter
Addicted Member
works a treat,
i'll probably be posting again later tho, changeserviceconfig looms.
lol
thanks for the help
Due to the energy crisis, the light at the end of the tunnel has been turned off.
Sorry for any inconvenience this may cause
Jun 8th, 2001, 06:59 AM
#7
Thread Starter
Addicted Member
ere we go again
iChangeServiceConfigResult = ChangeServiceConfig(iOpenService, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, Null, Null, Null, Null, Null, "password" & vbNullChar, sServiceName)
invalid use of null, <which one>, i tried following msdn and according to what i interpereted (laugh) i should have got it right. all i want to do is change the password.
Due to the energy crisis, the light at the end of the tunnel has been turned off.
Sorry for any inconvenience this may cause
Jun 8th, 2001, 08:48 AM
#8
Fanatic Member
Code:
iChangeServiceConfigResult = ChangeServiceConfig(iOpenService, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, vbNullString, vbNullString, 0&, vbNullString, vbNullString, "password" & vbNullChar, sServiceName)
I cant make it work cause I have no services which have passwords I can change, but this might work.....
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
Jun 8th, 2001, 09:12 AM
#9
Fanatic Member
heres a C++ sample from MSDN, but it shows you the right order in which tomake the calls, and also the right flags to use,
Attached Files
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
Nov 21st, 2002, 11:12 AM
#10
Hyperactive Member
hi all,
I am trying to manipulate NT Services and have got this piece of code...
VB Code:
Declare Function ChangeServiceConfig Lib "advapi32.dll" Alias "ChangeServiceConfigA" _
(ByVal hService As Long, ByVal dwServiceType As Long, _
ByVal dwStartType As Long, ByVal dwErrorControl As Long, _
ByVal lpBinaryPathName As String, ByVal lpLoadOrderGroup As String, _
lpdwTagId As Long, ByVal lpDependencies As String, ByVal lpServiceStartName As String, _
ByVal lpPassword As String, ByVal lpDisplayName As String) As Long
...in my declarations.
I use this code to change the configuration of a particular service to automatically start....
VB Code:
lConfigResult = ChangeServiceConfig(lhService, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, vbNullString, vbNullString, 0&, vbNullString, vbNullString, vbNullString, service)
...but I get an error 87 .. Invalid Parameter.
I have opened the service successfully as I can view properties on it (ie is it running etc).
any ideas???
"I'm Brian and so is my Wife"
Jul 29th, 2003, 02:49 AM
#11
Thread Starter
Addicted Member
sorry, it was quite a while ago ...
i dont think it was ever completed ... i kept locking the database every time i tried changing the settings
Due to the energy crisis, the light at the end of the tunnel has been turned off.
Sorry for any inconvenience this may cause
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width