[英]Programmatically open Advanced Security Settings dialog?
Is there a way to open the Advanced Security Settings dialog for a directory/file programmatically? 有没有办法以编程方式打开目录/文件的高级安全设置对话框? This is the dialog I want to open: 这是我要打开的对话框:
You open it by clicking the Advanced button on the Security properties dialog for the directory/file. 通过单击目录/文件的“安全属性”对话框中的“高级”按钮打开它。
There is this answer that shows how to open the Security properties tab using ShellExecuteEx
, so perhaps there are different parameters that can be used to open the Advanced Security Settings dialog directly, but I don't know where to find documentation (or where to look in the registry) for the verbs/parameters supported. 这个答案显示了如何使用ShellExecuteEx
打开安全属性选项卡,因此可能有不同的参数可用于直接打开高级安全设置对话框,但我不知道在哪里可以找到文档(或在哪里查看在注册表中)支持的动词/参数。
There is also the EditSecurityAdvanced
API, but it looks like that requires implementing the functionality to get/set the ACL instead of using the functionality built in to the Windows shell. 还有EditSecurityAdvanced
API,但看起来需要实现获取/设置ACL的功能,而不是使用内置于Windows shell的功能。
I'm working in VB.NET, but can translate C# or Windows API calls as needed, and pointers for how to do my own research would also be appreciated. 我正在使用VB.NET,但可以根据需要翻译C#或Windows API调用,并且我们也会感激指导如何进行自己的研究。
I couldn't find a direct way of opening it either. 我也找不到打开它的直接方法。 Using automation like the commentator Visual Vincent suggested isn't too hard. 使用Visual Vincent建议的评论员这样的自动化并不太难。 Don't forget to add references to the assemblies and import System.Windows.Automation
不要忘记添加对程序集的引用并导入System.Windows.Automation
Then this code should press the Advanced
button for you. 然后此代码应按下“ Advanced
按钮。 This way still creates the main properties dialog though. 这种方式仍然会创建主要属性对话框。
Dim FileName As String = "The file name you are viewing the properties of"
Dim AE As AutomationElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, New PropertyCondition(AutomationElement.NameProperty, FileName + " Properties"))
Dim Advancedbtn = AE.FindFirst(TreeScope.Element Or TreeScope.Descendants, New PropertyCondition(AutomationElement.NameProperty, "Advanced"))
TryCast(Advancedbtn.GetCurrentPattern(InvokePattern.Pattern), InvokePattern).Invoke()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.