[英]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.