简体   繁体   中英

Why is my windows shell extension being invoked when I run an executable as administrator?

I'm working on a project that integrates with the Windows 10 file explorer to allow users to open selected files in our program. The shell extension I made works fine for the most part, but the problem I'm having is that my extension's IShellExtInit::Initialize(...) and IContextMenu::InvokeCommand(...) are being invoked when I right click an executable in my start menu results and click "Run as administrator". As far as I can tell, the only point in my code where I can confirm that my extension should actually be running when it is invoked is in DllGetClassObject(...) by checking that rclsid and my extension's GUID are equal.

For the basic setup of the shell extension, I followed this video series . The example extension in the videos only appeared for text files, but I changed mine to work on all file types.

Does anyone have any idea where this problem could be coming from? Here are the relevant parts of my code: https://gist.github.com/caevrobe/2865b5f472d668352a7a91fb5c66953a

I found a solution to this issue here . My fix was to return E_INVALIDARG if pici->lpVerb:= NULL in my IContextMenu:.InvokeCommand(...). When invoking "Run as administrator" pici->lpVerb was "runas", When using my extension through the context menu normally. it was null.

HRESULT MyContextMenuHandler::InvokeCommand(LPCMINVOKECOMMANDINFO pici) {
    if (pici->lpVerb != NULL)
        return E_INVALIDARG;
    // rest of your code...
}

I'll leave the question up in case anyone else has the same issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM