PDA

Click to See Complete Forum and Search --> : is "ANYONE" any good with services


aturner
Jun 8th, 2001, 03:52 AM
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:rolleyes: :rolleyes:

aturner
Jun 8th, 2001, 05:22 AM
the getservicekeyname isnt giving me a result, can anyone help??

crispin
Jun 8th, 2001, 05:56 AM
zip up the project and i'll see what I can do, for a fellow westcountryman (OOAARRR)...

aturner
Jun 8th, 2001, 06:04 AM
i got a brand new vb project, an i'll give u the bugs

crispin
Jun 8th, 2001, 06:21 AM
you got 50 lines o' code

and I got forty three.....


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

aturner
Jun 8th, 2001, 06:29 AM
works a treat,

i'll probably be posting again later tho, changeserviceconfig looms.

lol

thanks for the help :D

aturner
Jun 8th, 2001, 06:59 AM
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.

crispin
Jun 8th, 2001, 08:48 AM
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
Jun 8th, 2001, 09:12 AM
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,

LeeSalter
Nov 21st, 2002, 10:12 AM
hi all,

I am trying to manipulate NT Services and have got this piece of 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....



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???

aturner
Jul 29th, 2003, 02:49 AM
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