Interop.shell32.ShellClass in .NET core code example
Example 1: shell32.dll c# example
public void onStartup()
{
Shell32.Shell shell = new Shell32.Shell();
Shell32.Folder objFolder = shell.NameSpace(@"C:\Windows");
this.files.Clear();
foreach (string name in ColumnListPerName)
this.files.Columns.Add(name);
foreach (int id in ColumnListPerID)
{
string header = objFolder.GetDetailsOf(null, id);
if (String.IsNullOrEmpty(header))
break;
while (this.files.Columns.Contains(header))
header += "_";
header = header.Replace("'", "_").Replace("’", "_");
Debug.WriteLine("creating column named " + header);
this.files.Columns.Add(header);
}
this.files.Columns["ID"].DataType = Type.GetType("System.Int32");
this.files.Columns[objFolder.GetDetailsOf(null, 26).Replace("'", "_").Replace("’", "_")].DataType = Type.GetType("System.Int32");
this.files.Columns["URI"].DataType = typeof(System.Uri);
ProcessLibraries();
this.files.AcceptChanges();
}
Example 2: shell32.dll c# example
public static string GetLnkTarget(string lnkPath)
{
try
{
var shl = new Shell32.Shell();
var dir = shl.NameSpace(System.IO.Path.GetDirectoryName(lnkPath));
var itm = dir.Items().Item(System.IO.Path.GetFileName(lnkPath));
var lnk = (Shell32.ShellLinkObject)itm.GetLink;
return lnk.Target.Path;
}
catch (Exception)
{
return lnkPath;
}
}