Microsoft.VisualStudio.Project.DragDropHelper.GetData C# (CSharp) Method

GetData() private method

private GetData ( Microsoft dataObject, FORMATETC &fmtetc ) : STGMEDIUM
dataObject Microsoft
fmtetc FORMATETC
return STGMEDIUM
        public static STGMEDIUM GetData(Microsoft.VisualStudio.OLE.Interop.IDataObject dataObject, ref FORMATETC fmtetc)
        {
            if (dataObject == null)
                throw new ArgumentNullException("dataObject");

            FORMATETC[] af = new FORMATETC[1];
            af[0] = fmtetc;
            STGMEDIUM[] sm = new STGMEDIUM[1];
            dataObject.GetData(af, sm);
            fmtetc = af[0];
            return sm[0];
        }

Same methods

DragDropHelper::GetData ( SafeGlobalAllocHandle dropHandle ) : string

Usage Example

Esempio n. 1
0
        public static string GetSourceProjectPath(Microsoft.VisualStudio.OLE.Interop.IDataObject dataObject)
        {
            string    projectPath = null;
            FORMATETC fmtetc      = CreateFormatEtc(CF_VSPROJECTCLIPDESCRIPTOR);

            if (QueryGetData(dataObject, ref fmtetc) == VSConstants.S_OK)
            {
                STGMEDIUM stgmedium = DragDropHelper.GetData(dataObject, ref fmtetc);
                if (stgmedium.tymed == (uint)TYMED.TYMED_HGLOBAL)
                {
                    // We are releasing the cloned hglobal here.
                    IntPtr dropInfoHandle = stgmedium.unionmember;
                    if (dropInfoHandle != IntPtr.Zero)
                    {
                        try
                        {
                            string path = GetData(dropInfoHandle);

                            // Clone the path that we can release our memory.
                            if (!String.IsNullOrEmpty(path))
                            {
                                projectPath = String.Copy(path);
                            }
                        }
                        finally
                        {
                            Marshal.FreeHGlobal(dropInfoHandle);
                        }
                    }
                }
            }

            return(projectPath);
        }
All Usage Examples Of Microsoft.VisualStudio.Project.DragDropHelper::GetData