I'm having a problem which I can't seem to find a solution to, and since I'm not much of a COM expert (learned the basics by myself over the last month or so), I thought I'd ask around to see if there is a solution to my problem. I am working with visual studio 2003 (VC++) and right now I have a main program (MFC dialog-based exe) that wants to access some Administrator-level permissions when a certain dialog-box in opened. I read a bit about this and found out it is not possible to give administrative privileges to an already running process, and that I needed to use the COM elevation moniker to create a new process with administrative rights. (http://msdn.microsoft.com/en-us/library/windows/desktop/ms679687%28v=vs.85%29.aspx) That's where the problem begins.
Right now, I have a COM atl dll (with MFC support, merging of the proxy/stub code and support for COM+), and I need to host an ActiveX control (based on IWebBrowser2) in the one dialog contained (MFC Dialog) in this dll. However, after going through the elevation process and calling the exposed method to show the dialog, it always fails to launch/display. I have been looking around for solutions, and stumbled around some things, but cannot seem to fix the problem. Here are some things I have done :
-Added AfxEnableControlContainer() in the dll's InitInstance + CoInitializeEx(NULL, COINIT_MULTITHREAD) in the thread that calls the dll. This actually causes the program to get an assertion fail (wincore.cpp, line 884, afxmaphwnd == NULL apparently) when trying to call the dialog's DoModal().
-I tried purely removing the ActiveX control inside the dialog and if I do so, it seems to work fine, so the problem really looks like it's linked with the ActiveX control.
-I tried creating a non-modal dialog (never know I guess) but the same problem occurs
I have observed that in the output I get the following errors when the dialog is created (don't know if it is the cause or consequence of my problem though) First-chance exception at ... : 0x800706BE: The remote procedure call failed. First-chance exception at ... : 0x800706BA: The RPC server is unavailable.
I might be missing something very basic (student at University right now, so I might not know some stuff that may seem obvious to some), so if anyone has an idea about what might be wrong, please tell me.
User contributions licensed under CC BY-SA 3.0