Click here to Skip to main content
13,148,427 members (62,383 online)
Rate this:
Please Sign up or sign in to vote.

I have a COM dll with a class in it.

I have an app with a UAC level of asInvoker. This app creates a COM object as administrator.

Everything works fine running as administrator, and even logged in as standard user, right->click runas administrator.

However, when I log in as standard user and double-click, I see the UAC elevation prompt when my class gets invoked. I enter in the correct password, and the COM object creation passes, but I get an access denied error (0x80070005).

Anybody have any clues? Also, do you know of any great debuggers that I may use to solve this?

More Info:

I am building it in VS 2008, but it is using visual studio version 2.0 with MFC setting to 'using standard windows libraries' and Use of ATL set to 'Dynamic Link to ATL'

In the rgs file for the class whose object I am creating, I add the following:
NoRemove CLSID
  ForceRemove {<class-guid>} = s 'CDCRegistryWriter Class'
    ProgID = s <ClassName>.1'
    VersionIndependentProgID = s '<className>'
    ForceRemove 'Programmable'
    InprocServer32 = s '%MODULE%'
      val ThreadingModel = s 'Apartment'
    val AppID = s '%APPID%'
    'TypeLib' = s '<library-guid>'
        val Enabled = d 1
        val IconReference = s 'applicationIcon'
    val LocalizedString = s '@%MODULE%,-100'

The above settings, set the following keys:

HKLM\Software\Classes\CLSID\My ClassID (found in ClassName.rgs)\AppID (a string set to My AppGuid)
HKLM\Software\Classes\CLSID\My ClassID\LocalizedString (an expanding string set to @dllPath.dll,-100(where 100 is a string
in the string table)).

HKLM\Software\Classes\CLSID\My ClassID\Elevation\Enabled (a DWORD set to 1)

HKLM\Software\Classes\CLSID\My ClassID\Elevation\IconReference (An expanding string set to 'applicationIcon')

I add the following to the rgs file for the dll
  NoRemove AppID
    '%APPID%' = s '<AppName>'
      val DllSurrogate = s ''
      val ROTFlags = s '1'
      val AppID = s '%APPID%'

The above code adds the following keys to the registry:
ses\AppID\My AppGuid(found in dllMain.h)>\ROTFlags(a string set to "1")
HKLM\Software\Classes\AppID\My AppGuid\DllSurrogate(a string set to empty)

Also, my calling code uses the standard old

HRESULT CallingClass::CoCreateInstanceAsAdmin(HWND hwnd,REFCLSID rClsid, REFIID rIid, void** ppv)
    HRESULT     hr;
    BIND_OPTS3	bo;
    WCHAR		wszCLSID[255];
    WCHAR		wszMonikerName[300];
    hr = StringCchPrintf(
      . . .ShowMyDebugMessage		
      return hr;
    memset(&bo, 0, sizeof(bo));
    bo.cbStruct	= sizeof(bo);
    bo.hwnd	= hwnd;
    bo.dwClassContext = CLSCTX_LOCAL_SERVER;
    return CoGetObject(wszMonikerName, 
        &bo, rIid, ppv );
    . . .Show my debug message
    return E_FAIL;
  return S_OK;
Posted 26-Jan-12 3:14am
Updated 31-Jan-12 7:06am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170924.2 | Last Updated 31 Jan 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100