本文整理汇总了C#中IShellLinkW类的典型用法代码示例。如果您正苦于以下问题:C# IShellLinkW类的具体用法?C# IShellLinkW怎么用?C# IShellLinkW使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IShellLinkW类属于命名空间,在下文中一共展示了IShellLinkW类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public void Create (string file_path, string target_path)
{
link = (IShellLinkW) new CShellLink ();
this.link.SetShowCmd (1);
this.link.SetPath (target_path);
(this.link as IPersistFile).Save (file_path, true);
}
示例2: ShellLink
/// <summary>
/// Creates an instance of the Shell Link object.
/// </summary>
public ShellLink()
{
if (System.Environment.OSVersion.Platform == PlatformID.Win32NT) {
linkW = (IShellLinkW)new CShellLink();
} else {
linkA = (IShellLinkA)new CShellLink();
}
}
示例3: ShellShortcut
///
/// <param name='linkPath'>
/// Path to new or existing shortcut file (.lnk).
/// </param>
///
public ShellShortcut(string linkPath)
{
IPersistFile pf;
m_sPath = linkPath;
m_Link = (IShellLinkW) new ShellLink();
if (File.Exists(linkPath)) {
pf = (IPersistFile) m_Link;
pf.Load(linkPath, 0);
}
}
示例4: ShellLink
public ShellLink(string lnkPath)
{
this.lnkPath = lnkPath;
if (Unicode)
{
_slW = (IShellLinkW)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(CLSID_ShellLink)));
((IPersistFile)(_slW)).Load(lnkPath, 0);
}
else
{
_slA = (IShellLinkA)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(CLSID_ShellLink)));
((IPersistFile)(_slA)).Load(lnkPath, 0);
}
}
示例5: ShellLink
/// <summary>
/// Constructor with creating shell link object and loading shortcut file
/// </summary>
/// <param name="shortcutPath">Shortcut file path</param>
public ShellLink(string shortcutPath)
{
try
{
shellLink = (IShellLinkW)new CShellLink();
}
catch (Exception ex)
{
throw new COMException("Failed to create Shell link object.", ex);
}
if (shortcutPath != null) // To avoid default constructor
this.Load(shortcutPath);
}
示例6: _SHAddToRecentDocs_ShellLink
private static extern void _SHAddToRecentDocs_ShellLink(SHARD uFlags, IShellLinkW pv);
示例7: SHAddToRecentDocs
internal static void SHAddToRecentDocs(IShellLinkW shellLink)
{
SHAddToRecentDocs_ShellLink(SHARD.LINK, shellLink);
}
示例8: ShellLinkToString
/// <summary>
/// Generate a unique string for the ShellLink that can be used for equality checks.
/// </summary>
private static string ShellLinkToString(IShellLinkW shellLink)
{
var pathBuilder = new StringBuilder((int)Win32Value.MAX_PATH);
shellLink.GetPath(pathBuilder, pathBuilder.Capacity, null, SLGP.RAWPATH);
string title = null;
// Need to use the property store to get the title for the link.
using (PROPVARIANT pv = new PROPVARIANT())
{
var propStore = (IPropertyStore)shellLink;
PKEY pkeyTitle = PKEY.Title;
propStore.GetValue(ref pkeyTitle, pv);
// PKEY_Title should be an LPWSTR if it's not empty.
title = pv.GetValue() ?? "";
}
var argsBuilder = new StringBuilder((int)Win32Value.INFOTIPSIZE);
shellLink.GetArguments(argsBuilder, argsBuilder.Capacity);
// Path and title should be case insensitive.
// Shell treats arguments as case sensitive because apps can handle those differently.
return pathBuilder.ToString().ToUpperInvariant() + title.ToUpperInvariant() + argsBuilder.ToString();
}
示例9: ShellLink
public ShellLink(string linkFile)
{
try
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
shellLinkW = (IShellLinkW)new ShellLinkObject();
shellLinkA = null;
}
else
{
shellLinkA = (IShellLinkA)new ShellLinkObject();
shellLinkW = null;
}
}
catch
{
throw new COMException("cannot create ShellLinkObject");
}
if (linkFile != null)
Load(linkFile);
}
示例10: KfSymlink
public KfSymlink(LinkType shortcutlinkType)
{
dataBuffer = new StringBuilder(260);
// Get a pointer to the IShellLink interface.
switch (shortcutlinkType)
{
case LinkType.File:
psl = (IShellLinkW) Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(ClsidShellLink)), true);
break;
case LinkType.Folder:
psl = (IShellLinkW) Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(ClsidFolderShortcut)), true);
break;
}
}
示例11: ShellLinkUtility
/// <summary>
/// コンストラクタ
/// </summary>
/// <exception cref="COMException">IShellLinkインターフェイスを取得できませんでした。</exception>
public ShellLinkUtility()
{
currentFile = "";
shellLinkW = null;
shellLinkA = null;
try
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
// Unicode環境
shellLinkW = (IShellLinkW)(new ShellLinkObject());
isUnicodeEnvironment = true;
}
else
{
// Ansi環境
shellLinkA = (IShellLinkA)(new ShellLinkObject());
isUnicodeEnvironment = false;
}
}
catch
{
throw new COMException("IShellLinkインターフェイスを取得できませんでした。");
}
}
示例12: ShellLink
public ShellLink() {
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
linkW = (IShellLinkW) new CShellLink();
else
linkA = (IShellLinkA) new CShellLink();
}
示例13: SHAddToRecentDocs
public static extern void SHAddToRecentDocs(SHARD uFlags, IShellLinkW pv);
示例14: Dispose
public void Dispose () {
if (this.link == null )
return;
Marshal.ReleaseComObject (this.link);
this.link = null;
}
示例15: Dispose
//
// IDisplosable implementation
//
public void Dispose()
{
if (m_Link != null)
{
Marshal.ReleaseComObject(m_Link);
m_Link = null;
}
}