Example #1
0
 /// <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();
     }
 }
 internal ShellLink()
 {
     if (System.Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         linkW = (IShellLinkW) new CShellLink();
     }
     else
     {
         linkA = (IShellLinkA) new CShellLink();
     }
 }
Example #3
0
        //private string _shortcutFile = "";

        public ShellLink()
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                _linkW = (IShellLinkW) new CShellLink();
            }
            else
            {
                _linkA = (IShellLinkA) new CShellLink();
            }
        }
Example #4
0
 /// <summary>
 /// Creates an instance of the Shell Link object.
 /// </summary>
 public ShellLink()
 {
     if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
     {
         linkW = (IShellLinkW) new CShellLink();
     }
     else
     {
         linkA = (IShellLinkA) new CShellLink();
     }
 }
Example #5
0
 /// <summary>
 /// Creates an instance of the Shell Link object.
 /// </summary>
 public WindowsShortcut()
 {
     if (System.Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         linkW = (IShellLinkW) new CShellLink();
     }
     else
     {
         linkA = (IShellLinkA) new CShellLink();
     }
 }
Example #6
0
 public ShellLink()
 {
     this.shortcutFile = "";
     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         this.linkW = (IShellLinkW) new CShellLink();
     }
     else
     {
         this.linkA = (IShellLinkA) new CShellLink();
     }
 }
Example #7
0
 /// <summary>
 /// Dispose the object, releasing the COM Shortcut object
 /// </summary>
 public void Dispose()
 {
     if (linkW != null)
     {
         Marshal.ReleaseComObject(linkW);
         linkW = null;
     }
     if (linkA != null)
     {
         Marshal.ReleaseComObject(linkA);
         linkA = null;
     }
 }
Example #8
0
 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);
     }
 }
Example #9
0
 /// <summary>
 /// Dispose the object, releasing the COM ShellLink object
 /// </summary>
 public void Dispose()
 {
     if (linkW != null)
     {
         Marshal.ReleaseComObject(linkW);
         linkW = null;
     }
     if (linkA != null)
     {
         Marshal.ReleaseComObject(linkA);
         linkA = null;
     }
     GC.SuppressFinalize(this);
 }
Example #10
0
 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);
     }
 }
Example #11
0
 /*public void Dispose()
  * {
  *      if (_linkW != null )
  *      {
  *              Marshal.ReleaseComObject(_linkW);
  *              _linkW = null;
  *      }
  *      if (_linkA != null)
  *      {
  *              Marshal.ReleaseComObject(_linkA);
  *              _linkA = null;
  *      }
  * }*/
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
     }
     if (_linkW != null)
     {
         Marshal.ReleaseComObject(_linkW);
         _linkW = null;
     }
     if (_linkA != null)
     {
         Marshal.ReleaseComObject(_linkA);
         _linkA = null;
     }
 }
Example #12
0
 private void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (disposing)
         {
             if (_linkW != null)
             {
                 Marshal.ReleaseComObject(_linkW);
                 _linkW = null;
             }
             if (_linkA != null)
             {
                 Marshal.ReleaseComObject(_linkA);
                 _linkA = null;
             }
         }
     }
 }
Example #13
0
 /// <summary>
 /// Dispose the object, releasing the COM ShellLink object
 /// </summary>
 public void Dispose()
 {
     if (linkW != null)
     {
         if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
         {
             Marshal.ReleaseComObject(linkW);
             linkW = null;
         }
     }
     if (linkA != null)
     {
         if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
         {
             Marshal.ReleaseComObject(linkA);
         }
         linkA = null;
     }
 }
Example #14
0
        protected virtual void Dispose(Boolean disposing)
        {
            if (disposing)
            {
                // free managed resources
            }
            // free native resources

            if (linkW != null)
            {
                Marshal.ReleaseComObject(linkW);
                linkW = null;
            }
            if (linkA != null)
            {
                Marshal.ReleaseComObject(linkA);
                linkA = null;
            }
        }
Example #15
0
		/*public void Dispose()
		{
			if (_linkW != null ) 
			{
				Marshal.ReleaseComObject(_linkW);
				_linkW = null;
			}
			if (_linkA != null)
			{
				Marshal.ReleaseComObject(_linkA);
				_linkA = null;
			}
		}*/
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {

            }
            if (_linkW != null)
            {
                Marshal.ReleaseComObject(_linkW);
                _linkW = null;
            }
            if (_linkA != null)
            {
                Marshal.ReleaseComObject(_linkA);
                _linkA = null;
            }
        }
 public ShellLinkA(IShellLinkA Wrapped)
 {
     this.Wrapped = Wrapped;
 }
        /// <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インターフェイスを取得できませんでした。");
            }
        }
Example #18
0
 public ShellLink() {
     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
         linkW = (IShellLinkW) new CShellLink();
     else
         linkA = (IShellLinkA) new CShellLink();
 }
Example #19
0
        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);
        }
 public void Dispose()
 {
     if (this.PersistStream != null)
     {
         Marshal.FinalReleaseComObject(this.PersistStream);
     }
     this.LinkA = null;
     this.LinkW = null;
     this.PersistStream = null;
 }
 private void Initialize()
 {
     object obj2 = new CoShellLink();
     this.LinkW = obj2 as IShellLinkW;
     if (this.LinkW == null)
     {
         this.LinkA = obj2 as IShellLinkA;
         if (this.LinkA == null)
         {
             throw new NotSupportedException("IShellLink");
         }
     }
     this.PersistStream = obj2 as Microsoft.COM.IPersistStream;
     if (this.PersistStream == null)
     {
         throw new NotSupportedException("IPersistStream");
     }
 }
Example #22
0
        public void Load(string linkFileName)
        {
            if (null == linkFileName)
            {
                throw new ArgumentNullException("linkFileName", "A name of the link file cannot be null");
            }
            if (!File.Exists(linkFileName))
            {
                throw new FileNotFoundException("Link not found", linkFileName);
            }
            new FileIOPermission(FileIOPermissionAccess.Read | FileIOPermissionAccess.PathDiscovery, linkFileName).Demand();

            object sl = null;

            try
            {
                Type slType = Type.GetTypeFromCLSID(CLSID_ShellLink);
                sl = Activator.CreateInstance(slType);
                IPersistFile pf = sl as IPersistFile;
                pf.Load(linkFileName, 0);

                int           showCmd;
                StringBuilder builder    = new StringBuilder(INFOTIPSIZE);
                IShellLinkW   shellLinkW = sl as IShellLinkW;
                if (null == shellLinkW)
                {
                    IShellLinkA shellLinkA = sl as IShellLinkA;
                    if (null == shellLinkA)
                    {
                        ThrowInvalidComObjectException();
                    }
                    shellLinkA.GetArguments(builder, builder.Capacity);
                    this.arguments = builder.ToString();
                    shellLinkA.GetDescription(builder, builder.Capacity);
                    this.description = builder.ToString();
                    shellLinkA.GetHotkey(out this.hotkey);
                    shellLinkA.GetIconLocation(builder, builder.Capacity, out this.iconIndex);
                    this.iconPath = builder.ToString();
                    Win32FindDataA wfd;
                    shellLinkA.GetPath(builder, builder.Capacity, out wfd, SLGP_UNCPRIORITY);
                    this.path = builder.ToString();
                    shellLinkA.GetShowCmd(out showCmd);
                    shellLinkA.GetWorkingDirectory(builder, builder.Capacity);
                    this.workingDirectory = builder.ToString();
                }
                else
                {
                    shellLinkW.GetArguments(builder, builder.Capacity);
                    this.arguments = builder.ToString();
                    shellLinkW.GetDescription(builder, builder.Capacity);
                    this.description = builder.ToString();
                    shellLinkW.GetHotkey(out this.hotkey);
                    shellLinkW.GetIconLocation(builder, builder.Capacity, out this.iconIndex);
                    this.iconPath = builder.ToString();
                    Win32FindDataW wfd;
                    shellLinkW.GetPath(builder, builder.Capacity, out wfd, SLGP_UNCPRIORITY);
                    this.path = builder.ToString();
                    shellLinkW.GetShowCmd(out showCmd);
                    shellLinkW.GetWorkingDirectory(builder, builder.Capacity);
                    this.workingDirectory = builder.ToString();
                }
                this.showCmd = (ShowCommand)showCmd;
            }
            finally
            {
                if (null != sl)
                {
                    Marshal.ReleaseComObject(sl);
                }
            }
            // This object is not eligible for the garbage collection during this method call
            GC.KeepAlive(this);
        }
Example #23
0
 /// <summary>
 /// Dispose the object, releasing the COM ShellLink object
 /// </summary>
 public void Dispose()
 {
     if (linkW != null )
      {
     Marshal.ReleaseComObject(linkW);
     linkW = null;
      }
      if (linkA != null)
      {
     Marshal.ReleaseComObject(linkA);
     linkA = null;
      }
 }
Example #24
0
 private void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (disposing)
         {
             if (_linkW != null)
             {
                 Marshal.ReleaseComObject(_linkW);
                 _linkW = null;
             }
             if (_linkA != null)
             {
                 Marshal.ReleaseComObject(_linkA);
                 _linkA = null;
             }
         }
     }
 }