private static unsafe HRESULT GetDataHere(IntPtr thisPtr, FORMATETC *format, STGMEDIUM_Raw *pMedium) { var instance = ComInterfaceDispatch.GetInstance <IDataObject>((ComInterfaceDispatch *)thisPtr); try { STGMEDIUM medium = new() { pUnkForRelease = pMedium->pUnkForRelease == IntPtr.Zero ? null : Marshal.GetObjectForIUnknown(pMedium->pUnkForRelease), tymed = pMedium->tymed, unionmember = pMedium->unionmember, }; instance.GetDataHere(ref *format, ref medium); pMedium->pUnkForRelease = medium.pUnkForRelease == null ? IntPtr.Zero : Marshal.GetIUnknownForObject(medium.pUnkForRelease); pMedium->tymed = medium.tymed; pMedium->unionmember = medium.unionmember; return(HRESULT.S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return((HRESULT)ex.HResult); } }
private static unsafe HRESULT DAdvise(IntPtr thisPtr, FORMATETC *pFormatetc, ADVF advf, IntPtr pAdviseSink, int *connection) { var instance = ComInterfaceDispatch.GetInstance <IDataObject>((ComInterfaceDispatch *)thisPtr); var adviseSink = (IAdviseSink)Marshal.GetObjectForIUnknown(pAdviseSink); return((HRESULT)instance.DAdvise(ref *pFormatetc, advf, adviseSink, out *connection)); }
private static int Next(IntPtr thisPtr, int celt, FORMATETC *rgelt, int *pceltFetched) { try { IEnumFORMATETC instance = ComInterfaceDispatch.GetInstance <IEnumFORMATETC>((ComInterfaceDispatch *)thisPtr); FORMATETC[] elt = new FORMATETC[celt]; int[] celtFetched = new int[1]; // Eliminate null bang after https://github.com/dotnet/runtime/pull/68537 lands, or // IEnumFORMATETC annotations would be corrected. var result = instance.Next(celt, elt, pceltFetched is null ? null ! : celtFetched); for (var i = 0; i < celt; i++) { rgelt[i] = elt[i]; } if (pceltFetched is not null) { *pceltFetched = celtFetched[0]; } return(result); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Drop(IntPtr thisPtr, IntPtr pDataObj, uint grfKeyState, Point pt, uint *pdwEffect) { Ole32.IDropTarget inst = ComInterfaceDispatch.GetInstance <Ole32.IDropTarget>((ComInterfaceDispatch *)thisPtr); var dataObject = WinFormsComWrappers.Instance.GetOrCreateObjectForComInstance(pDataObj, CreateObjectFlags.Unwrap); return((int)inst.Drop(dataObject, grfKeyState, pt, ref *pdwEffect)); }
public static int GetIDsOfNames( IntPtr thisPtr, Guid *iid, IntPtr *namesRaw, int namesCount, int lcid, int *dispIdsRaw) { try { // Marshal arguments to managed types. var names = new string[namesCount]; for (int i = 0; i < namesCount; ++i) { names[i] = Marshal.PtrToStringUni(namesRaw[i]) !; } var inst = ComInterfaceDispatch.GetInstance <IDispatch>((ComInterfaceDispatch *)thisPtr); var dispIds = new int[names.Length]; inst.GetIDsOfNames(ref *iid, names, namesCount, lcid, dispIds); // Marshal out disp IDs. for (int i = 0; i < dispIds.Length; ++i) { dispIdsRaw[i] = dispIds[i]; } } catch (Exception e) { return(e.HResult); } return(0); // S_OK; }
private static int UnlockRegion(IntPtr thisPtr, ulong libOffset, ulong cb, uint dwLockType) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); return((int)inst.UnlockRegion(libOffset, cb, dwLockType)); } catch (Exception ex) { return(ex.HResult); } }
private static int DragOver(IntPtr thisPtr, uint grfKeyState, Point pt, uint *pdwEffect) { try { Ole32.IDropTarget instance = ComInterfaceDispatch.GetInstance <Ole32.IDropTarget>((ComInterfaceDispatch *)thisPtr); return((int)instance.DragOver(grfKeyState, pt, ref *pdwEffect)); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Clone(IntPtr thisPtr, IntPtr *ppstm) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); return((int)inst.Clone(ppstm)); } catch (Exception e) { return(e.HResult); } }
private static int CopyTo(IntPtr thisPtr, IntPtr pstm, ulong cb, ulong *pcbRead, ulong *pcbWritten) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); return((int)inst.CopyTo(pstm, cb, pcbRead, pcbWritten)); } catch (Exception e) { return(e.HResult); } }
private static int Skip(IntPtr thisPtr, int celt) { try { IEnumString instance = ComInterfaceDispatch.GetInstance <IEnumString>((ComInterfaceDispatch *)thisPtr); return(instance.Skip(celt)); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static unsafe HRESULT EnumDAdvise(IntPtr thisPtr, IntPtr *pEnumAdvise) { var instance = ComInterfaceDispatch.GetInstance <IDataObject>((ComInterfaceDispatch *)thisPtr); var result = (HRESULT)instance.EnumDAdvise(out var enumAdvice); if (result.Failed()) { return(result); } result = WinFormsComWrappers.Instance.TryGetComPointer(enumAdvice, IID.IEnumSTATDATA, out var enumAdvicePtr); return(result); }
private static int DragLeave(IntPtr thisPtr) { try { Ole32.IDropTarget instance = ComInterfaceDispatch.GetInstance <Ole32.IDropTarget>((ComInterfaceDispatch *)thisPtr); return((int)instance.DragLeave()); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
public static int OnSelectionChange(IntPtr thisPtr, IntPtr pfd) { try { Shell32.IFileDialogEvents inst = ComInterfaceDispatch.GetInstance <Shell32.IFileDialogEvents>((ComInterfaceDispatch *)thisPtr); Shell32.IFileDialog fd = (Shell32.IFileDialog)Instance.GetOrCreateObjectForComInstance(pfd, CreateObjectFlags.Unwrap); return((int)inst.OnSelectionChange(fd)); } catch (Exception ex) { return(ex.HResult); } }
private static HRESULT GiveFeedback(IntPtr thisPtr, Ole32.DROPEFFECT dwEffect) { try { var instance = ComInterfaceDispatch.GetInstance <Ole32.IDropSource>((ComInterfaceDispatch *)thisPtr); return(instance.GiveFeedback(dwEffect)); } catch (Exception ex) { Debug.WriteLine(ex); return((HRESULT)ex.HResult); } }
private static HRESULT QueryContinueDrag(IntPtr thisPtr, BOOL fEscapePressed, User32.MK grfKeyState) { try { var instance = ComInterfaceDispatch.GetInstance <Ole32.IDropSource>((ComInterfaceDispatch *)thisPtr); return(instance.QueryContinueDrag(fEscapePressed, grfKeyState)); } catch (Exception ex) { Debug.WriteLine(ex); return((HRESULT)ex.HResult); } }
private static int Write(IntPtr thisPtr, byte *pv, uint cb, uint *pcbWritten) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.Write(pv, cb, pcbWritten); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Stat(IntPtr thisPtr, Interop.Ole32.STATSTG *pstatstg, Interop.Ole32.STATFLAG grfStatFlag) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.Stat(out *pstatstg, grfStatFlag); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Revert(IntPtr thisPtr) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.Revert(); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Commit(IntPtr thisPtr, uint grfCommitFlags) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.Commit((Interop.Ole32.STGC)grfCommitFlags); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Commit(IntPtr thisPtr, uint grfCommitFlags) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); inst.Commit(grfCommitFlags); } catch (Exception e) { return(e.HResult); } return(S_OK); }
public static int OnFolderChanging(IntPtr thisPtr, IntPtr pfd, IntPtr psiFolder) { try { Shell32.IFileDialogEvents inst = ComInterfaceDispatch.GetInstance <Shell32.IFileDialogEvents>((ComInterfaceDispatch *)thisPtr); Shell32.IFileDialog fd = (Shell32.IFileDialog)Instance.GetOrCreateObjectForComInstance(pfd, CreateObjectFlags.Unwrap); Shell32.IShellItem siFolder = (Shell32.IShellItem)Instance.GetOrCreateObjectForComInstance(psiFolder, CreateObjectFlags.Unwrap); return((int)inst.OnFolderChanging(fd, siFolder)); } catch (Exception ex) { return(ex.HResult); } }
private static int Read(IntPtr thisPtr, byte *pv, uint cb, uint *pcbRead) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); inst.Read(pv, cb, pcbRead); } catch (Exception ex) { return(ex.HResult); } return(S_OK); }
private static int Revert(IntPtr thisPtr) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); inst.Revert(); } catch (Exception e) { return(e.HResult); } return(S_OK); }
private static int Reset(IntPtr thisPtr) { try { IEnumFORMATETC instance = ComInterfaceDispatch.GetInstance <IEnumFORMATETC>((ComInterfaceDispatch *)thisPtr); instance.Reset(); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Stat(IntPtr thisPtr, Interop.Ole32.STATSTG *pstatstg, Interop.Ole32.STATFLAG grfStatFlag) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); inst.Stat(pstatstg, grfStatFlag); } catch (Exception e) { return(e.HResult); } return(S_OK); }
public static int OnShareViolation(IntPtr thisPtr, IntPtr pfd, IntPtr psi, Shell32.FDESVR *pResponse) { try { Shell32.IFileDialogEvents inst = ComInterfaceDispatch.GetInstance <Shell32.IFileDialogEvents>((ComInterfaceDispatch *)thisPtr); Shell32.IFileDialog fd = (Shell32.IFileDialog)Instance.GetOrCreateObjectForComInstance(pfd, CreateObjectFlags.Unwrap); Shell32.IShellItem si = (Shell32.IShellItem)Instance.GetOrCreateObjectForComInstance(psi, CreateObjectFlags.Unwrap); return((int)inst.OnShareViolation(fd, si, pResponse)); } catch (Exception ex) { return(ex.HResult); } }
public static int GetProviderOptionsInternal(IntPtr thisPtr, out ProviderOptions i) { i = 0; try { var inst = ComInterfaceDispatch.GetInstance <IRawElementProviderSimple>((ComInterfaceDispatch *)thisPtr); i = inst.ProviderOptions; } catch (Exception e) { return(e.HResult); } return(0); // S_OK; }
private static int Seek(IntPtr thisPtr, long dlibMove, SeekOrigin dwOrigin, ulong *plibNewPosition) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.Seek(dlibMove, dwOrigin, plibNewPosition); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int SetSize(IntPtr thisPtr, ulong libNewSize) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.SetSize(libNewSize); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Drop(IntPtr thisPtr, IntPtr pDataObj, uint grfKeyState, Point pt, uint *pdwEffect) { try { Ole32.IDropTarget instance = ComInterfaceDispatch.GetInstance <Ole32.IDropTarget>((ComInterfaceDispatch *)thisPtr); var dataObject = WinFormsComWrappers.Instance.GetOrCreateObjectForComInstance(pDataObj, CreateObjectFlags.Unwrap); return((int)instance.Drop(dataObject, grfKeyState, pt, ref *pdwEffect)); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }