?
Solved

Using OLE Servers under NT Service

Posted on 2002-04-01
10
Medium Priority
?
287 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
[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
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

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!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

752 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