Windows Service Framework

Share your advanced PureBasic knowledge/code with the community.
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

SkyManager wrote:This link seems not working
Ring's NTService library is part of the PBOSL suite - and has been for quite some time. Check out http://www.purebasic.fr/english/viewtopic.php?t=17100
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Post by SkyManager »

When I run the PBOL4 example and perform a "-u" uninstallation, the NTService status is changed into "Disabled" and not remove from the NT Service list.
What can we do to fix this :?:
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Post by techjunkie »

SkyManager wrote:When I run the PBOL4 example and perform a "-u" uninstallation, the NTService status is changed into "Disabled" and not remove from the NT Service list.
What can we do to fix this :?:
Works fine for me, on WinXP Pro SP2.
[EDIT]
That is, if I stop the service before the uninstall. Haven't tried without it, but that seems stupid... :roll:
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Post by SkyManager »

I am using W2K+SP4 with PB4.02
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Post by techjunkie »

SkyManager wrote:I am using W2K+SP4 with PB4.02
I have another machine with the same config, I can give it a try - but it should work... :wink:
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Post by techjunkie »

If you specify either SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS, and the service is running in the context of the LocalSystem account, you can also specify the following value.

Code: Select all

#SERVICE_INTERACTIVE_PROCESS = $100
so the service can interact with the Desktop.

Example,

Code: Select all

T_SERVICE = CreateService_(T_SCMANAGER, AppExeName, ServiceName, #SERVICE_ALL_ACCESS, (#SERVICE_WIN32_OWN_PROCESS | #SERVICE_INTERACTIVE_PROCESS), #SERVICE_DEMAND_START, #SERVICE_ERROR_NORMAL, AppHome + AppExeFileName, 0, 0, 0, 0, 0) 
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
maw

Post by maw »

Be ware though, that in Vista, Server 2008 and all future Windows versions interactive services doesn't work! This is also true if you use Fast User Switching in XP. The service will start as usual but can neither show output or recieve input from a user!

Here is an explaination of why: http://blogs.technet.com/voy/archive/20 ... erver.aspx

techjunkie wrote:If you specify either SERVICE_WIN32_OWN_PROCESS
or SERVICE_WIN32_SHARE_PROCESS, and the service is running in the context of the LocalSystem account, you can also specify the following value.

Code: Select all

#SERVICE_INTERACTIVE_PROCESS = $100
so the service can interact with the Desktop.

Example,

Code: Select all

T_SERVICE = CreateService_(T_SCMANAGER, AppExeName, ServiceName, #SERVICE_ALL_ACCESS, (#SERVICE_WIN32_OWN_PROCESS | #SERVICE_INTERACTIVE_PROCESS), #SERVICE_DEMAND_START, #SERVICE_ERROR_NORMAL, AppHome + AppExeFileName, 0, 0, 0, 0, 0) 
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Post by techjunkie »

maw wrote:Be ware though, that in Vista, Server 2008 and all future Windows versions interactive services doesn't work! This is also true if you use Fast User Switching in XP.
Thanks! :D I must test that on my Vista machine. I just use it to get the Window Handlers when the service is started with the System account - I must see what happens on Vista... :lol:
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
rootbear
New User
New User
Posts: 4
Joined: Wed Sep 28, 2011 2:47 pm

Re: Windows Service Framework

Post by rootbear »

it's amazing that after a couple of years, the code is still valid!

I got another 'crash' issue here, i should call myself mr. crash ;)

here you go:

copy & paste the code and tested, working!

and then I added EnableExplicit, did adjustment here and there,

myservice -i
net start myservice

wait, it crashes!!

copy and paste the original code again, it's still working without crash!

i start to compare my version with original version, the only things i added are
poorman's debug like:

Code: Select all

_WriteLog("into function ServiceMain ")
and i start to remove those lines from my version step by step.
still crashes, keep doing so till ... i remove this line

Code: Select all

Procedure ServiceMain()
;;_WriteLog("into function ServiceMain ")
voila!

but WHY?!
Post Reply