Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using OLE Servers under NT Service

Posted on 2002-04-01
10
Medium Priority
?
288 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

618 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