Solved

Using OLE Servers under NT Service

Posted on 2002-04-01
10
282 Views
Last Modified: 2010-04-04
I want to write an NT Service that uses the TOutlookApplication server (Delphi 6), to watch for incoming emails.

I wrote a simple test app that hooks the NewMail event, and that worked fine.

No when I tried to convert this to an NT Service I get an error when trying to connect.

The error message was ...
"Service failed on execute: CoInitialize has not been called."

I found a reference that suggested manually calling CoInitialize, but this has just changed the error...
"Service failed on execute: Server execution failed."

Is there a limitation which prevents me from doing what I want to do?

Can you suggest an alternative?
0
Comment
Question by:Hamlet081299
10 Comments
 

Expert Comment

by:classics
ID: 6911963
Does this sort of service need to run in a particular user context?
0
 
LVL 5

Author Comment

by:Hamlet081299
ID: 6911975
Maybe.  I've tried it various ways but still have problems.  

In some cases the service gets "stuck" in a "Starting" state, and the only way I can kill it then is to restart my machine.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6912512
when do you execute your startup code ?
as the help sais you should minimize the execution code in the startup of the service (OnStart event)
also any errors occuring in the startup event will result in failing to startup the service
0
 
LVL 5

Author Comment

by:Hamlet081299
ID: 6912529
I have no code in the OnStart I initialize things at the start of the OnExcute.  Maybe that's the problem?
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6913943
nope it's not
while the code in the OnExecute event is executed the Service runs
when the code exits the service stops
so you should do some loop in there like : InitStuff; while not Stopped do begin ... end; FinalizeStuff;
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 5

Author Comment

by:Hamlet081299
ID: 6914246
yep. That's pretty much what I do.

I've come to the point now where I'm resigned to just writing it as a regular app and putting it in the tray.

With that in mind I have decided to delete this question.
0
 
LVL 1

Accepted Solution

by:
Moondancer earned 0 total points
ID: 6979131
200 points refunded, this question moved to the PAQ at zero points rather than deleting it, since it "may" help others.

Moondancer - EE Moderator
0
 
LVL 6

Expert Comment

by:PHD
ID: 7281121
Hello,
I have the same problem do you find the solution ?

thanks

Philippe
0
 
LVL 5

Author Comment

by:Hamlet081299
ID: 7296321
I never did find a solution that used this technique.  

What I did do that worked, was to write the whole thing using Extended MAPI, but that's a whole new kettle of fish.

That was a while ago now, and it was pretty complex to get it all going ... to complex to easily comment on here.

If you want to go down this path I would suggest you get some good references on Extended MAPI.  I ended up hunting around through various components and things, but in the end had to write most of it myself.

Good luck.
0
 

Expert Comment

by:SaPHeRMaXX
ID: 7587936
Well, I do not find a way to contact you directly. I can only be hopeful that you'll find my request. I am looking for exactyl what you already did: hook into the MAPI _NewMail event to be able to react to new mails on an exchange server. Could you please try to contact me or post the source code??

Yours, Arne   (arnebaier@web.de)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now