Vista UAC, Access Elevation and .Net

I am trying to figure out if there is a way to raise a specific function in an application. For example, I have an application with system and user settings that are stored in the registry, I only need the height when it is necessary to change the system settings.

Unfortunately, all the information I came across only speaks of the beginning of a new process with elevated privileges.

+5
source share
6 answers

What you really need to do is save your settings in the Application Data folder.

+2
source

, . , . - , .

, COM-, , COM-, :

HRESULT 
CreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv)
{
    WCHAR monikerName[1024];
    WCHAR clsid[1024];
    BIND_OPTS3 bo;

    StringFromGUID2 (guid, clsid, sizeof (clsid) / 2);

    swprintf_s (monikerName, sizeof (monikerName) / 2, L"Elevation:Administrator!new:%s", clsid);

    memset (&bo, 0, sizeof (bo));
    bo.cbStruct = sizeof (bo);
    bo.hwnd = hwnd;
    bo.dwClassContext = CLSCTX_LOCAL_SERVER;

    // Prevent the GUI from being half-rendered when the UAC prompt "freezes" it
    MSG paintMsg;
    int MsgCounter = 5000;  // Avoid endless processing of paint messages
    while (PeekMessage (&paintMsg, hwnd, 0, 0, PM_REMOVE | PM_QS_PAINT) != 0 && --MsgCounter > 0)
    {
        DispatchMessage (&paintMsg);
    }

    return CoGetObject (monikerName, &bo, iid, ppv);
}
+11
+7

, :

. - - , . , . .

, ++, , , P/Invoke. .NET.

+3

"SDK- -" Windows SDK "UACDemo", # Windows Forms, , (, %programfiles%).

. , .Net Remoting IPC , .

+3

, . Named Pipes .NET 3.5 IPC .

0
source

All Articles