| |
|
|
- Page 1 - |
|
![: 05/19/05](.././../../i/a/noavatar.gif) | Hello Profaner...
gives it a Possibility one Program at Shutdown the Rechners finish as a last To let? |
|
|
| |
|
|
|
| |
|
- Page 1 - |
|
![: 05/20/05](.././../../i/a/noavatar.gif) | Hello Thomas...
[quote:e3a546d485] You yourself as a last, not more than as service or Skript on NT-Systemen. I faith but the meets it not yet, or ??? [/quote:e3a546d485] possible meets it the still. under windows9x would very the The Solution (RegisterServiceProcess), there need I But not. One further trouble would, the my service one Window had. I could me present, the NT there evtl. with the Zugriffsrechten something streikt - there should I Perhaps still one little tricksen... unfortunately have I none blassen Schimmer, How I NT a service installiere. can you - or otherwise someone - me Perhaps on The Sprünge help? |
|
|
| |
|
|
|
![: 05/20/05](.././../../i/a/noavatar.gif) | [quote:6298a5d2c1=AH] unfortunately have I none blassen Schimmer, How I NT a service installiere. can you - or otherwise someone - me Perhaps on The Sprünge help?[/quote:6298a5d2c1] Have you what from the CodeArchiv for PureBasic rausgesucht. can it you first standing, Perhaps too yourself transfer, otherwise meldest you again. isn't heavy (for me is XProfan schwerer ) CompileMarkSeparation; English forum:
; Author: Richard Eikeland
; Date: 12. April 2003
; angepaßt an 3.93 ts-soft
; Apr. 12, 2003
; Converted to PB by Richard Eikeland
; This code is posted as is with out any waranties.
;
#SERVICE_WIN32_OWN_PROCESS = $10
#SERVICE_WIN32_SHARE_PROCESS = $20
#SERVICE_WIN32 = #SERVICE_WIN32_OWN_PROCESS + #SERVICE_WIN32_SHARE_PROCESS
#SERVICE_ACCEPT_STOP = $1
#SERVICE_ACCEPT_PAUSE_CONTINUE = $2
#SERVICE_ACCEPT_SHUTDOWN = $4
#SC_MANAGER_CONNECT = $1
#SC_MANAGER_CREATE_SERVICE = $2
#SC_MANAGER_ENUMERATE_SERVICE = $4
#SC_MANAGER_LOCK = $8
#SC_MANAGER_QUERY_LOCK_STATUS = $10
#SC_MANAGER_MODIFY_BOOT_CONFIG = $20
#STANDARD_RIGHTS_REQUIRED = $F0000
#SERVICE_QUERY_CONFIG = $1
#SERVICE_CHANGE_CONFIG = $2
#SERVICE_QUERY_STATUS = $4
#SERVICE_ENUMERATE_DEPENDENTS = $8
#SERVICE_START = $10
#SERVICE_STOP = $20
#SERVICE_PAUSE_CONTINUE = $40
#SERVICE_INTERROGATE = $80
#SERVICE_USER_DEFINED_CONTROL = $100
;#SERVICE_ALL_ACCESS = #STANDARD_RIGHTS_REQUIRED | #SERVICE_QUERY_CONFIG | #SERVICE_CHANGE_CONFIG | #SERVICE_QUERY_STATUS | #SERVICE_ENUMERATE_DEPENDENTS | #SERVICE_START | #SERVICE_STOP | #SERVICE_PAUSE_CONTINUE | #SERVICE_INTERROGATE |#SERVICE_USER_DEFINED_CONTROL
#SERVICE_DEMAND_START = $3
#SERVICE_ERROR_NORMAL = $1
;- SERVICE_CONTROL
#SERVICE_CONTROL_STOP = $1
#SERVICE_CONTROL_PAUSE = $2
#SERVICE_CONTROL_CONTINUE = $3
#SERVICE_CONTROL_INTERROGATE = $4
#SERVICE_CONTROL_SHUTDOWN = $5
;-SERVICE_STATE
#SERVICE_STOPPED = $1
#SERVICE_START_PENDING = $2
#SERVICE_STOP_PENDING = $3
#SERVICE_RUNNING = $4
#SERVICE_CONTINUE_PENDING = $5
#SERVICE_PAUSE_PENDING = $6
#SERVICE_PAUSED = $7
Global ServiceStatus.SERVICE_STATUS, hServiceStatus.l, SERVICE_NAME.s, Finish.l
Declare Handler(fdwControl.l)
Declare ServiceMain(dwArgc.l, lpszArgv.l)
Declare WriteLog(Value.s)
Procedure Main()
hSCManager.l
hService.l
ServiceTableEntry.SERVICE_TABLE_ENTRY
b.l
cmd.s
;Change SERVICE_NAME and app name as needed
AppPath.s = "C:DevPureBasicworkdirNTServiceMyService.exe"
SERVICE_NAME = "MyService"
cmd = Trim(LCase(ProgramParameter()))
Select cmd
Case "install" ;Install service on machine
hSCManager = OpenSCManager_(0, 0, #SC_MANAGER_CREATE_SERVICE)
hService = CreateService_(hSCManager, SERVICE_NAME, SERVICE_NAME, #SERVICE_ALL_ACCESS, #SERVICE_WIN32_OWN_PROCESS, #SERVICE_DEMAND_START, #SERVICE_ERROR_NORMAL, AppPath, 0, 0, 0, 0, 0)
CloseServiceHandle_(hService)
CloseServiceHandle_(hSCManager)
Finish = 1
Case "uninstall" ;Remove service from machine
hSCManager = OpenSCManager_(0, 0, #SC_MANAGER_CREATE_SERVICE)
hService = OpenService_(hSCManager, SERVICE_NAME, #SERVICE_ALL_ACCESS)
DeleteService_(hService)
CloseServiceHandle_(hService)
CloseServiceHandle_(hSCManager)
Finish = 1
Default
*sname.s = SERVICE_NAME
;Start the service
ServiceTableEntrylpServiceName = @SERVICE_NAME
ServiceTableEntrylpServiceProc = @ServiceMain()
b = StartServiceCtrlDispatcher_(@ServiceTableEntry)
WriteLog("Starting Service bResult=" + Str(b))
If b = 0
Finish = 1
EndIf
EndSelect
Repeat
Until Finish =1
End
EndProcedure
Procedure Handler(fdwControl.l)
b.l
Select fdwControl
Case #SERVICE_CONTROL_PAUSE
;** Do whatever it takes To pause here.
ServiceStatusdwCurrentState = #SERVICE_PAUSED
Case #SERVICE_CONTROL_CONTINUE
;** Do whatever it takes To continue here.
ServiceStatusdwCurrentState = #SERVICE_RUNNING
Case #SERVICE_CONTROL_STOP
ServiceStatusdwWin32ExitCode = 0
ServiceStatusdwCurrentState = #SERVICE_STOP_PENDING
ServiceStatusdwCheckPoint = 0
ServiceStatusdwWaitHint = 0 ;Might want a time estimate
b = SetServiceStatus_(hServiceStatus, ServiceStatus)
;** Do whatever it takes to stop here.
Finish = 1
ServiceStatusdwCurrentState = #SERVICE_STOPPED
Case #SERVICE_CONTROL_INTERROGATE
;Fall through To send current status.
Finish = 1
;Else
EndSelect
;Send current status.
b = SetServiceStatus_(hServiceStatus, ServiceStatus)
EndProcedure
Procedure ServiceMain(dwArgc.l, lpszArgv.l)
b.l
WriteLog("ServiceMain")
;Set initial state
ServiceStatusdwServiceType = #SERVICE_WIN32_OWN_PROCESS
ServiceStatusdwCurrentState = #SERVICE_START_PENDING
ServiceStatusdwControlsAccepted = #SERVICE_ACCEPT_STOP | #SERVICE_ACCEPT_PAUSE_CONTINUE | #SERVICE_ACCEPT_SHUTDOWN
ServiceStatusdwWin32ExitCode = 0
ServiceStatusdwServiceSpecificExitCode = 0
ServiceStatusdwCheckPoint = 0
ServiceStatusdwWaitHint = 0
hServiceStatus = RegisterServiceCtrlHandler_(SERVICE_NAME, @Handler())
ServiceStatusdwCurrentState = #SERVICE_START_PENDING
b = SetServiceStatus_(hServiceStatus, ServiceStatus)
;** Do Initialization Here
ServiceStatusdwCurrentState = #SERVICE_RUNNING
b = SetServiceStatus_(hServiceStatus, ServiceStatus)
;** Perform tasks -- If none exit
;** If an error occurs the following should be used for shutting
;** down:
; SetServerStatus SERVICE_STOP_PENDING
; Clean up
; SetServerStatus SERVICE_STOPPED
EndProcedure
Procedure WriteLog(Value.s)
sfile.s = "MyServiceLog.txt"
If OpenFile(0, sfile)
WriteStringN(Value)
CloseFile(0)
Else
If CreateFile(0,sfile)
WriteStringN(Value)
CloseFile(0)
EndIf
EndIf
EndProcedure
Main()
white now mere not what the HL with the code power
Greeting thomas (ts-soft) |
|
|
| |
|
|
|
![iF: 05/20/05](.././../../i/a/1.gif) | The code becomes nothing benefit - there wirken only PureBasic-command for PureBasic-Compiler - and the compiliert Yes native.
In C++ z.B. ists eigendlich too only a Projekteinstellung - circa as service To compilieren.
salvo. |
|
|
| |
|
|
|
![: 05/20/05](.././../../i/a/noavatar.gif) | *.l are long *.s are string *.b are byte *Hello hierbei deals it itself circa strukturen
#xxxx are konstanten
functions with _ end are Api-functions
Greeting Thomas
![](.././../../i/s/qq5.gif) |
|
|
| |
|
|
|
![: 05/20/05](.././../../i/a/noavatar.gif) | [quote:676b84de14=iF]The code becomes nothing benefit - there wirken only PureBasic-command for PureBasic-Compiler - and the compiliert Yes native.
In C++ z.B. ists eigendlich too only a Projekteinstellung - circa as service To compilieren.
salvo.[/quote:676b84de14]there liegste something wrong, think I, only API Call with gefüllten Structures, as well as auswertung the übergebenen Commandos. ought to machbar his. the Program becomes only as service registered and reacted correspond to. If AH itself the respected has, and means it could so weg, I will it to XProfan umsetzen, hope I
Greeting Thomas |
|
|
| |
|
|
| |
|
- Page 2 - |
|
|
![iF: 05/20/05](.././../../i/a/1.gif) | ok.
salvo. ![](.././../../i/s/__upl_ext_1111498478.gif) |
|
|
| |
|
|
|
![CB: 05/20/05](.././../../i/a/188878350943cea808357ab.jpg) CB | Hello Andreas! [quote:4cca043a78]unfortunately have I none blassen Schimmer, How I NT a service installiere. can you - or otherwise someone - me Perhaps on The Sprünge help?[/quote:4cca043a78] integrally simply: (Admin) Systemsteuerung - management - services. Ggf. must You before in Menu adjust: management Show enable. Re. mouse on a service - properties. and already can You yourself calm.
Christian |
|
|
| |
|
|
|
![: 05/20/05](.././../../i/a/noavatar.gif) | fine Thanks for eure Mithilfe, there's already very plenty brauchbares thereby.
@Thomas: In Profan know I right well from - with others Languages sees the already badly from . The APIs, The in your View source vorkommen, correspond to really them, The I me bislang respected have (CreateService, OpenSCManager). The thing should means too in Profan machbar his. all ? Happen? stand apparently too with drin (habs only überflogen), shining means in the principle useable To his...
@Christian: thanks for Tipp, i'll time look, whether the under 2000 too goes! |
|
|
| |
|
|
|
![: 05/20/05](.././../../i/a/noavatar.gif) | Hello Andreas, Have time one Teilstück the Codes to XProfan Translated, so the the remainder really simply To ersehen is. i hope so helps you moreover. CompileMarkSeparation $H windows.ph
$H Structs.ph
Global ServiceStatus.SERVICE_STATUS, hServiceStatus.l, SERVICE_NAME.s, Finish.l
Declare ServiceStatus# , hServiceStatus&, SERVICE_NAME$, Finish&
Dim ServiceStatus#, ~SERVICE_STATUS
Procedure Handler(fdwControl.l)
b.l
Select fdwControl
Case #SERVICE_CONTROL_PAUSE
;** Do whatever it takes To pause here.
ServiceStatusdwCurrentState = #SERVICE_PAUSED
Case #SERVICE_CONTROL_CONTINUE
;** Do whatever it takes To continue here.
ServiceStatusdwCurrentState = #SERVICE_RUNNING
Case #SERVICE_CONTROL_STOP
ServiceStatusdwWin32ExitCode = 0
ServiceStatusdwCurrentState = #SERVICE_STOP_PENDING
ServiceStatusdwCheckPoint = 0
ServiceStatusdwWaitHint = 0 ;Might want a time estimate
b = SetServiceStatus_(hServiceStatus, ServiceStatus)
;** Do whatever it takes to stop here.
Finish = 1
ServiceStatusdwCurrentState = #SERVICE_STOPPED
Case #SERVICE_CONTROL_INTERROGATE
;Fall through To send current status.
Finish = 1
;Else
EndSelect
;Send current status.
b = SetServiceStatus_(hServiceStatus, ServiceStatus)
EndProcedure
Proc Handler
Parameters fdwControl&
If fdwControl& = ~SERVICE_CONTROL_PAUSE
** Do whatever it takes To pause here.
ServiceStatus#.dwCurrentState = ~SERVICE_PAUSED
ElseIf fdwControl& = ~SERVICE_CONTROL_CONTINUE
** Do whatever it takes To continue here.
ServiceStatus#.dwCurrentState = ~SERVICE_RUNNING
ElseIf fdwControl& = ~SERVICE_CONTROL_STOP
ElseIf fdwControl& = ~SERVICE_CONTROL_INTERROGATE
EndIf
~SetServiceStatus(hServiceStatus&, Addr(ServiceStatus#))
../references-fonction/XProfan/endproc/'>ENDPROC
is only so much, How for Translation necessary is. If You do not get by, I will whom remainder too adjust, the can then but something last, I yet others items manage must
Greeting Thomas |
|
|
| |
|
|
|
![: 05/20/05](.././../../i/a/noavatar.gif) | ... can something last, To I so keep busy can, i think but, I come clear. best Thanks!
![](.././../../i/s/__upl_ext_1111498557.gif) |
|
|
| |
|
|
|
![: 07/15/05](.././../../i/a/noavatar.gif) | The Solution for my trouble shining The API SetProcessShutdownParameters To his. |
|
|
| |
|
|
|
![: 07/16/05](.././../../i/a/noavatar.gif) | OK, the was The Solution. with this API can itself determine, when very my application at Shutdown terminates. |
|
|
| |
|
|