示例#1
0
        int IShellExtInit.Initialize(IntPtr pidlFolder, IntPtr lpdobj, uint hKeyProgID)
        {
            try
            {
                m_dataObject = null;
                if (lpdobj != (IntPtr)0)
                {
                    // Get info about the directory
                    m_dataObject = (IDataObject)Marshal.GetObjectForIUnknown(lpdobj);
                    FORMATETC fmt = new FORMATETC();
                    fmt.cfFormat = CLIPFORMAT.CF_HDROP;
                    fmt.ptd		 = 0;
                    fmt.dwAspect = DVASPECT.DVASPECT_CONTENT;
                    fmt.lindex	 = -1;
                    fmt.tymed	 = TYMED.TYMED_HGLOBAL;
                    STGMEDIUM medium = new STGMEDIUM();
                    m_dataObject.GetData(ref fmt, ref medium);
                    m_hDrop = medium.hGlobal;

                    // Now retrieve the menu information from the registry
                    RegistryKey sc = Registry.LocalMachine;
                    sc = sc.OpenSubKey("Software\\Microsoft\\ShellCmd", true);
                    if (sc.SubKeyCount > 0)
                    {
                        m_items = new MenuItem[sc.SubKeyCount];
                        int	i=0;
                        foreach(string name in sc.GetSubKeyNames())
                        {
                            try
                            {
                                RegistryKey item = sc.OpenSubKey(name, true);
                                string command = (string)item.GetValue("");
                                MenuItem m = new MenuItem();
                                m.Text = name;
                                m.Command = command;
                                m_items[i] = m;
                                ++i;
                            }
                            catch(Exception)
                            {
                            }
                        }
                    }
                    else
                    {
                        m_items = new MenuItem[0];
                    }
                }
            }
            catch(Exception)
            {
            }
            return 0;
        }
示例#2
0
 int IShellExtInit.Initialize(IntPtr pidlFolder, IntPtr lpdobj, uint hKeyProgID)
 {
     try
     {
         if (lpdobj != (IntPtr)0)
         {
             // Get info about the directory
             IDataObject dataObject = (IDataObject)Marshal.GetObjectForIUnknown(lpdobj);
             FORMATETC fmt = new FORMATETC();
             fmt.cfFormat = CLIPFORMAT.CF_HDROP;
             fmt.ptd		 = 0;
             fmt.dwAspect = DVASPECT.DVASPECT_CONTENT;
             fmt.lindex	 = -1;
             fmt.tymed	 = TYMED.TYMED_HGLOBAL;
             STGMEDIUM medium = new STGMEDIUM();
             dataObject.GetData(ref fmt, ref medium);
             m_hDrop = medium.hGlobal;
         }
     }
     catch(Exception)
     {
     }
     return 0;
 }