|
-
February 19th, 2008, 01:21 PM
#1
ATL service, COM and problems
Hello,
I have an ATL service that is serving up a COM interface to another app I'm building. Here's the issue:
Code:
MULTI_QI qi;
HRESULT hr;
qi.pIID = &IID_ISecMan;
qi.pItf = NULL;
//qi.hr = 0;
hr = CoCreateInstanceEx(CLSID_SecMan, NULL, CLSCTX_LOCAL_SERVER, NULL, 1, &qi);
if (FAILED(hr))
{
throw -1;
}
When I compile the service and then immediately go to my app and run the code above, the CoCreateInstance() returns the OK result and everything goes fine. The COM calls fail of course, but that's expected from what I understand (I'm new to COM).
However, if I compile the service and then go to the command line and enter "smservice /service" to register it, the service manager lists SMService and I can start it.
Then I call the above code and instead of OK, it returns ACCESSDENIED every time. The only way to get it to stop is to completely remove SMService from the service manager.
What have I missed?
-
February 19th, 2008, 04:58 PM
#2
Re: ATL service, COM and problems
1. Why are you using CoCreateInstanceEx and not CoCreateInstance to create instances on your local machine?
2. Any reason that you are not using CLSCTX_ALL instead of CLSCTX_LOCAL_SERVER?
-
February 19th, 2008, 06:21 PM
#3
Re: ATL service, COM and problems
 Originally Posted by Siddhartha
1. Why are you using CoCreateInstanceEx and not CoCreateInstance to create instances on your local machine?
2. Any reason that you are not using CLSCTX_ALL instead of CLSCTX_LOCAL_SERVER?
1) Because I'm cutting and pasting that bit from another app that someone else in the shop made a couple of years ago. I don't really know the finer points of why to use one over the other, but his stuff works so I'm just going with it.
2) I looked at the descriptions of the enum and decided that was the best fit for my app. Was I wrong? I've tried other values to no effect.
As I'm typing this I was just alerted by someone about something called CoInitializeSecurity() or whatever he called it, I shall give that a try in a bit and see if maybe that is the issue.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|