简体   繁体   English

当我以管理员身份运行可执行文件时,为什么会调用我的 windows shell 扩展?

[英]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.我正在开发一个与 Windows 10 文件浏览器集成的项目,以允许用户在我们的程序中打开选定的文件。 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".我制作的 shell 扩展大部分工作正常,但我遇到的问题是我的扩展的 IShellExtInit::Initialize(...) 和 IContextMenu::InvokeCommand(...) 在我右键单击可执行文件在我的开始菜单结果中,然后单击“以管理员身份运行”。 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.据我所知,我的代码中唯一可以确认我的扩展在被调用时实际上应该运行的点是在DllGetClassObject(...)中,通过检查 rclsid 和我的扩展的 GUID 是否相等。

For the basic setup of the shell extension, I followed this video series .对于 shell 分机的基本设置,我遵循了这个视频系列 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以下是我的代码的相关部分: 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(...).如果 pici->lpVerb:= NULL 在我的 IContextMenu:.InvokeCommand(...) 中,我的修复是返回 E_INVALIDARG。 When invoking "Run as administrator" pici->lpVerb was "runas", When using my extension through the context menu normally.当调用“以管理员身份运行”时,pici->lpVerb 是“runas”,当通过上下文菜单正常使用我的扩展程序时。 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.我会留下这个问题,以防其他人遇到同样的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在开始菜单搜索中,覆盖“以管理员身份运行”的COM shell扩展失败 - COM shell extension to override “Run as Administrator” fails in start menu search 为什么从桌面运行程序时找不到我的声音文件? - Why is my sound file not being found when I run my program from the desktop? 为什么当我返回堆分配的对象而不是堆栈分配的对象时调用复制构造函数? - Why is copy constructor being invoked when I return a heap allocated object but not for stack allocated object? 为什么要调用构造函数? - Why is constructor being invoked? 可执行文件是否可以要求管理员权限? (Windows 7的) - Is it possible for the executable to ask for Administrator rights? (Windows 7) 为什么我的 Linux 编译的二进制文件在 Windows 上运行时不起作用? - Why does my Linux-compiled binary not work when I run it on Windows? 服务崩溃时如何以管理员权限运行程序? - How can I run a program with administrator permission when a service crashes? 为什么崩溃时在外壳中运行的可执行文件输出到stdout而不是stderr? - Why an executable running in shell output to stdout instead of stderr when crashes? 在Windows 7中调试shell扩展 - Debugging shell extension in Windows 7 为什么我的二进制文件可以在Windows 8上运行而不能在Windows 7上运行? - Why does my binary run on Windows 8 but not on Windows 7?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM