Page 1 of 1
Posted: Mon Aug 26, 2002 3:26 pm
by BackupUser
Restored from previous forum. Originally posted by pusztry.
Does anybody know how to add a programs as a services to a windows NT/2000/XP machine? I would like to just have that option in a network program I am writing.
Thanks
Ryan
WinXP, PIII 800 MHz, 512MB RAM, SB Live 5.1, NVidia TNT 2 Ultra
Posted: Mon Aug 26, 2002 6:09 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
I have code that worked really fine (long time ago) on W98 and PureBasic v2.x .
But I tested it on W2k (w98 no longer in use...) and it doesn't work anymore
Anyway, this is what I have, maybe it's a start...
Code: Select all
Procedure HideTask()
Shared RSP.l
; we must get the address of undocumented function
result = GetProcAddress_(GetModuleHandle_("kernel32.dll"), "RegisterServiceProcess")
If result
RSP = result ; save the address
push dword 1 ; hide
push dword 0 ; 0 = this process
call RSP ; call it
EndIf
EndProcedure
Procedure UnHideTask()
Shared RSP.l
; we must get the address of undocumented function
result = GetProcAddress_(GetModuleHandle_("kernel32.dll"), "RegisterServiceProcess")
If result
RSP = result ; save the address
push dword 0 ; well.. we don't have a function called
; "UnRegisterServiceProcess" BUT...
; if you put a 0 , you will "unhide" it >:)
push dword 0 ; this process. (but what about unhide others?)
call RSP ; call it
EndIf
EndProcedure
If OpenWindow(0, 200, 200, 320,240, #PB_Window_SystemMenu ,"Test to hide a application")
HideTask()
Delay(10000)
UnHideTask()
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
EndIf
End
Don't forget to enable inline ASM.
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.