[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using OLE Servers under NT Service

Posted on 2002-04-01
10
Medium Priority
?
289 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month19 days, 16 hours left to enroll

872 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