Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

NT Service

Posted on 2001-07-03
7
Medium Priority
?
649 Views
Last Modified: 2008-03-17
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.
0
Comment
Question by:frangers99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 6251251
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?
0
 

Author Comment

by:frangers99
ID: 6251510
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)
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 1200 total points
ID: 6251729
Edit uService.pas:

Add

  SERVICE_INTERACTIVE_PROCESS   = $00000100;

to the const section.


Change the line

    ServiceControlHandle := CreateService(SCManagerHandle ,PCHAR(FServiceName), PCHAR(FServiceDisplayName),
                            SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START,
                            SERVICE_ERROR_NORMAL, Path, nil, nil, nil, nil, nil);

to

    ServiceControlHandle := CreateService(SCManagerHandle ,PCHAR(FServiceName), PCHAR(FServiceDisplayName),
                            SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS or SERVICE_INTERACTIVE_PROCESS, SERVICE_DEMAND_START,
                            SERVICE_ERROR_NORMAL, Path, nil, nil, nil, nil, nil);
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:frangers99
ID: 6251948
Epsylon.
Thanks again, you always answer my questions so fast! That had me confused for quite a while.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6251981
:o)   Take a deep breath and breathe out s l o w l y .....

Thanks a lot for the points!
0
 

Author Comment

by:frangers99
ID: 6252488
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
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6262346
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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question