Exemplo n.º 1
0
        public void Clear()
        {
            PROPVARIANT var = this;

            PropVariantClear(ref var);

            vt         = (ushort)VarEnum.VT_EMPTY;
            wReserved1 = wReserved2 = wReserved3 = 0;
            p          = IntPtr.Zero;
            p2         = 0;
        }
Exemplo n.º 2
0
		private static IShellLink CreateShellLink (string title, string path, string arguments, string icon_path, int icon_pos)
		{
			try {
				IShellLink shell_link = (IShellLink) Activator.CreateInstance (Type.GetTypeFromCLSID (CLSID.ShellLink));
				shell_link.SetPath (path);

				if (!string.IsNullOrEmpty (arguments))
					shell_link.SetArguments (arguments);

				if (!string.IsNullOrEmpty (icon_path))
					shell_link.SetIconLocation (icon_path, icon_pos);

				IntPtr pps;
				Guid ipsiid = CLSID.IPropertyStore;

				Marshal.QueryInterface (Marshal.GetIUnknownForObject (shell_link), ref ipsiid, out pps);
				IPropertyStore property_store = (IPropertyStore) Marshal.GetTypedObjectForIUnknown (pps, typeof (IPropertyStore));

				PROPVARIANT propvar = new PROPVARIANT ();
				propvar.SetString (title);

				// PKEY_Title
				PROPERTYKEY PKEY_Title = new PROPERTYKEY ();
				PKEY_Title.fmtid = new Guid ("F29F85E0-4FF9-1068-AB91-08002B27B3D9");
				PKEY_Title.pid = 2;

				property_store.SetValue (ref PKEY_Title, ref propvar);
				property_store.Commit ();

				IntPtr psl;
				Guid psliid = CLSID.IShellLinkW;

				Marshal.QueryInterface (Marshal.GetIUnknownForObject (shell_link), ref psliid, out psl);
				IShellLink link = (IShellLink) Marshal.GetTypedObjectForIUnknown (psl, typeof (IShellLink));

				propvar.Clear ();

				Marshal.ReleaseComObject (property_store);
				property_store = null;

				Marshal.ReleaseComObject (shell_link);
				shell_link = null;

				return link;
			} catch (COMException e) {
				Logger.Error ("Error createing shell link: {0}\n{1}", e.Message, e.StackTrace);
			}

			return null;
		}
Exemplo n.º 3
0
		private extern static int PropVariantClear (ref PROPVARIANT pvar);
Exemplo n.º 4
0
 private extern static int PropVariantClear(ref PROPVARIANT pvar);