Link to home
Start Free TrialLog in
Avatar of frangers99
frangers99

asked on

NT Service

I had written a small monitoring program for Windows 98 and have started to convert it into a service for NT.

So far it looks good, i've used a template from http://www.jgsoftware.com/nt.htm -> the vpcsrvce.zip and the service installs, accesses all my modules and functions from the form and everything is great...until... i use the FindWindow command.

For some reason it just wont work when being used as part of a service. It just seems to return 0 always.

If you download the zip file above and replace the timer procedure 'beep' command with...

var h:hwnd;
begin
  h:= Findwindow (nil,'Registry Editor');
  if h <> 0 then beep;
end;

what would work as a program, seems to not work in the service form. Any ways to get around this problem... do i have to change one of the lines of code in the service procedures included?

I have already tested the equivalent program on NT and it runs fine, but i need it to run as a service, and i would preferably keep the template above as it is easy apart from this one small problem.

Thanks for your help.
Avatar of Motaz
Motaz

Did you try to make it Interactive service, try to change Interactive to True.

Did you test FindWindow with these parameters and it returns non-zero number when Registry editor is working?
Avatar of frangers99

ASKER

How do i make it interactive if im using the template above, i only have Delphi 4 Standard which means i dont have the wizards etc... and yes, it didnt beep when i started regedit (inferring that h must have been 0)
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Epsylon.
Thanks again, you always answer my questions so fast! That had me confused for quite a while.
:o)   Take a deep breath and breathe out s l o w l y .....

Thanks a lot for the points!
just one last thing.... i get a little popup everynow and then while the service is running, telling me everything is fine.... being an invisible monitor, i dont wanna any popups, where are they being called from and how do i remove them.

thanks
Sorry, it seems that I don't get any notifications anymore from question where my answer was accepted. A very serious bug in EE. I've reported to CS it but I don't get any response.

About your problem: look in uService. There are some writeln statement which my cause the popups.