如何使用Windows API代码包在ShellFile/ShellFolder/ShellObject对象上调用动词? [英] How to Invoke a Verb on a ShellFile/ShellFolder/ShellObject objects using Windows API Code Pack?

查看:296
本文介绍了如何使用Windows API代码包在ShellFile/ShellFolder/ShellObject对象上调用动词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找C#Vb.NET解决方案,以了解如何调用回收站中存储的ShellObject(ShellFileShellFolder)上的undelete动词.

I'm looking for a C# or Vb.NET solution to know how I can invoke the undelete verb on a ShellObject (ShellFile or ShellFolder) stored in the recycle bin.

我写的回收站部分,我只需要知道如何在已删除项目上调用动词即可.

The recycle bin part I've it written, what I only need is to know how to invoke a verb on a deleted item.

为了更好地理解我,我将显示此示例如何使用Shell32接口调用动词的示例,但在Windows API Code Pack库的ShellObject/ShellFile/ShellFolder项上找不到任何类似的方法, m有兴趣使用:

To understand me better I'll show this example of how I invoke a verb using the Shell32 Interface, but I can't find any similar method on the ShellObject/ShellFile/ShellFolder items of the Windows API Code Pack library where I'm interested to use:

Private SH As New Shell
Private RecycleBin As Folder = 
        SH.NameSpace(ShellSpecialFolderConstants.ssfBITBUCKET)

Dim RandomDeletedItem As FolderItem = RecycleBin.Items.Cast(Of FolderItem)(1)

RandomDeletedItem.InvokeVerb("undelete")

这应该是Windows API Code Pack不完整的等效项(在VB.NET中)

And this should be the Windows API Code Pack incompleted equivalent (In VB.NET)

Private Shared RecycleBin As IKnownFolder = KnownFolders.RecycleBin

Dim RandomDeletedItem As ShellObject = RecycleBin(1)
Dim RandomDeletedFile As ShellFile = RecycleBin(1)
Dim RandomDeletedFolder As ShellFolder = RecycleBin(1)

' Here I need to know how to invoke the "undelete" verb on each object above...

推荐答案

在给定文件解析名称的情况下,如何使用ShellExecuteEx取消删除回收站中的文件:

How to use ShellExecuteEx to undelete a file in the Recycling Bin given its parsing name:

    ' some file we got from the recycle bin iterating through the IShellItems:
    Dim sParsing As String = _
      "E:\$RECYCLE.BIN\S-1-5-21-2546332361-822210090-45395533-1001\$RTD2G1Z.PNG"
    Dim shex As New SHELLEXECUTEINFO
    shex.cbSize = Marshal.SizeOf(shex)

    ' Here we want ONLY the file name.
    shex.lpFile = Path.GetFileName(sParsing)

    ' Here we want the exact directory from the parsing name
    shex.lpDirectory = Path.GetDirectoryName(sParsing)
    shex.nShow = SW_SHOW  ' = 5
    '' here the verb is undelete, not restore.
    shex.lpVerb = "undelete"

    ShellExecuteEx(shex)

这篇关于如何使用Windows API代码包在ShellFile/ShellFolder/ShellObject对象上调用动词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆