Mar*_*ark 7 .net c# vb.net winapi
有没有办法以编程方式打开目录/文件的高级安全设置对话框?这是我要打开的对话框:
通过单击目录/文件的"安全属性"对话框中的"高级"按钮打开它.
有这样的回答显示了如何使用打开安全属性标签ShellExecuteEx,所以也许有一些可以用来打开高级安全设置对话框,直接不同的参数,但我不知道在哪里可以找到文档(或在哪里看的注册表)支持的动词/参数.
还有EditSecurityAdvancedAPI,但看起来需要实现获取/设置ACL的功能,而不是使用内置于Windows shell的功能.
我正在使用VB.NET,但可以根据需要翻译C#或Windows API调用,并且我们也会感激指导如何进行自己的研究.
我也找不到直接打开它的方法。像评论员 Visual Vincent 建议的那样使用自动化并不难。不要忘记添加对程序集的引用并导入System.Windows.Automation
那么这段代码应该会Advanced为你按下按钮。不过,这种方式仍然会创建主要属性对话框。
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()
Run Code Online (Sandbox Code Playgroud)