Ejemplo n.º 1
0
 int IShellExtInit.Initialize(IntPtr pidlFolder, IntPtr lpdobj, uint hKeyProgID)
 {
     try
     {
         m_dataObject = null;
         if (lpdobj != (IntPtr)0)
         {
             m_dataObject = (ShellLib.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;
         }
     }
     catch (Exception)
     {
     }
     return S_OK;
 }
Ejemplo n.º 2
0
        int IShellExtInit.Initialize(IntPtr pidlFolder, IntPtr lpdobj, uint hKeyProgID)
        {
            try
            {
                m_dataObject = null;
                if (lpdobj != (IntPtr)0)
                {
                    m_dataObject = (ShellLib.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;
                }

                StringBuilder sbTemp = new StringBuilder(1024);
                if (ShellLib.Helpers.SHGetPathFromIDList(pidlFolder, sbTemp))
                {
                    m_szFoderPath = sbTemp.ToString();
                }
                else
                {
                    m_szFoderPath = null;
                }
            }
            catch (Exception)
            {
                return S_FALSE;
            }
            return S_OK;
        }