The .Net DataObject class implements the COM/OLE IDataObject interface , so
how do I get it.
I have tried this, but it does not work :
// Declare the COM/OLE IDataObject interface
[ComImport, Guid("0000010E-0000-0000-C000-000000000046"),
InterfaceType(C omInterfaceType .InterfaceIsIUn known)]
public interface IOleDataObject
{
[PreserveSig]
int OleGetData(FORM ATETC pFormatetc, [Out] STGMEDIUM pMedium);
[PreserveSig]
int OleGetDataHere( FORMATETC pFormatetc, [In, Out] STGMEDIUM pMedium);
[PreserveSig]
int OleQueryGetData (FORMATETC pFormatetc);
[PreserveSig]
int OleGetCanonical FormatEtc(FORMA TETC pformatectIn, [Out] FORMATETC
pformatetcOut);
[PreserveSig]
int OleSetData(FORM ATETC pFormatectIn, STGMEDIUM pmedium, int fRelease);
[return: MarshalAs(Unman agedType.Interf ace)]
IEnumFORMATETC OleEnumFormatEt c([In, MarshalAs(Unman agedType.U4)] int
dwDirection);
[PreserveSig]
int OleDAdvise(FORM ATETC pFormatetc, [In, MarshalAs(Unman agedType.U4)] int
advf, [In, MarshalAs(Unman agedType.Interf ace)] object pAdvSink, [Out,
MarshalAs(Unman agedType.LPArra y)] int[] pdwConnection);
[PreserveSig]
int OleDUnadvise([In, MarshalAs(Unman agedType.U4)] int dwConnection);
[PreserveSig]
int OleEnumDAdvise([Out, MarshalAs(Unman agedType.LPArra y)] object[]
ppenumAdvise);
}
-------------------
DataObject data = new DataObject();
IOleDataObject ido = data as IOleDataObject
--------------
When this is run, ido is null. I have also tried varrious other methods like
using Marshal.GetIUnk nownForObject, Marshal.QueryIn terface,
Marshal.GetType dObjectForIUnkn own, but none of the approaches work.
What am I doing wrong?
Thanks
Bob 4 5961
Bob,
You can use the IDataObject in the
System.Runtime. InteropServices .ComTypes namespace. It is the one you are
looking for.
The DataObject class in the System.Windows. Forms namespace implements
this as well.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Bob Staheli" <st*********@gm ail.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. . The .Net DataObject class implements the COM/OLE IDataObject interface , so how do I get it.
I have tried this, but it does not work :
// Declare the COM/OLE IDataObject interface
[ComImport, Guid("0000010E-0000-0000-C000-000000000046"), InterfaceType(C omInterfaceType .InterfaceIsIUn known)] public interface IOleDataObject { [PreserveSig] int OleGetData(FORM ATETC pFormatetc, [Out] STGMEDIUM pMedium); [PreserveSig] int OleGetDataHere( FORMATETC pFormatetc, [In, Out] STGMEDIUM pMedium); [PreserveSig] int OleQueryGetData (FORMATETC pFormatetc); [PreserveSig] int OleGetCanonical FormatEtc(FORMA TETC pformatectIn, [Out] FORMATETC pformatetcOut); [PreserveSig] int OleSetData(FORM ATETC pFormatectIn, STGMEDIUM pmedium, int fRelease); [return: MarshalAs(Unman agedType.Interf ace)] IEnumFORMATETC OleEnumFormatEt c([In, MarshalAs(Unman agedType.U4)] int dwDirection); [PreserveSig] int OleDAdvise(FORM ATETC pFormatetc, [In, MarshalAs(Unman agedType.U4)] int advf, [In, MarshalAs(Unman agedType.Interf ace)] object pAdvSink, [Out, MarshalAs(Unman agedType.LPArra y)] int[] pdwConnection); [PreserveSig] int OleDUnadvise([In, MarshalAs(Unman agedType.U4)] int dwConnection); [PreserveSig] int OleEnumDAdvise([Out, MarshalAs(Unman agedType.LPArra y)] object[] ppenumAdvise); }
-------------------
DataObject data = new DataObject(); IOleDataObject ido = data as IOleDataObject --------------
When this is run, ido is null. I have also tried varrious other methods like using Marshal.GetIUnk nownForObject, Marshal.QueryIn terface, Marshal.GetType dObjectForIUnkn own, but none of the approaches work.
What am I doing wrong?
Thanks Bob
Hi Nicholas,
Thanks for your reply.
However, System.Runtime. InteropServices .ComTypes.IData Object is only
present in .Net 2.0. I am using .Net 1.1.
How can I do that in this case?
Bob
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:Ot******** ******@TK2MSFTN GP12.phx.gbl... Bob,
You can use the IDataObject in the System.Runtime. InteropServices .ComTypes namespace. It is the one you are looking for.
The DataObject class in the System.Windows. Forms namespace implements this as well.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bob Staheli" <st*********@gm ail.com> wrote in message news:%2******** *******@tk2msft ngp13.phx.gbl.. . The .Net DataObject class implements the COM/OLE IDataObject interface , so how do I get it.
I have tried this, but it does not work :
// Declare the COM/OLE IDataObject interface
[ComImport, Guid("0000010E-0000-0000-C000-000000000046"), InterfaceType(C omInterfaceType .InterfaceIsIUn known)] public interface IOleDataObject { [PreserveSig] int OleGetData(FORM ATETC pFormatetc, [Out] STGMEDIUM pMedium); [PreserveSig] int OleGetDataHere( FORMATETC pFormatetc, [In, Out] STGMEDIUM pMedium); [PreserveSig] int OleQueryGetData (FORMATETC pFormatetc); [PreserveSig] int OleGetCanonical FormatEtc(FORMA TETC pformatectIn, [Out] FORMATETC pformatetcOut); [PreserveSig] int OleSetData(FORM ATETC pFormatectIn, STGMEDIUM pmedium, int fRelease); [return: MarshalAs(Unman agedType.Interf ace)] IEnumFORMATETC OleEnumFormatEt c([In, MarshalAs(Unman agedType.U4)] int dwDirection); [PreserveSig] int OleDAdvise(FORM ATETC pFormatetc, [In, MarshalAs(Unman agedType.U4)] int advf, [In, MarshalAs(Unman agedType.Interf ace)] object pAdvSink, [Out, MarshalAs(Unman agedType.LPArra y)] int[] pdwConnection); [PreserveSig] int OleDUnadvise([In, MarshalAs(Unman agedType.U4)] int dwConnection); [PreserveSig] int OleEnumDAdvise([Out, MarshalAs(Unman agedType.LPArra y)] object[] ppenumAdvise); }
-------------------
DataObject data = new DataObject(); IOleDataObject ido = data as IOleDataObject --------------
When this is run, ido is null. I have also tried varrious other methods like using Marshal.GetIUnk nownForObject, Marshal.QueryIn terface, Marshal.GetType dObjectForIUnkn own, but none of the approaches work.
What am I doing wrong?
Thanks Bob
Bob,
You should be able to declare this in your code, and it should work:
[ComImport, InterfaceType(C omInterfaceType .InterfaceIsIUn known),
Guid("0000010E-0000-0000-C000-000000000046")]
public interface IDataObject
{
void GetData([In] ref FORMATETC format, out STGMEDIUM medium);
void GetDataHere([In] ref FORMATETC format, ref STGMEDIUM medium);
[PreserveSig]
int QueryGetData([In] ref FORMATETC format);
[PreserveSig]
int GetCanonicalFor matEtc([In] ref FORMATETC formatIn, out FORMATETC
formatOut);
void SetData([In] ref FORMATETC formatIn, [In] ref STGMEDIUM medium,
[MarshalAs(Unman agedType.Bool)] bool release);
IEnumFORMATETC EnumFormatEtc(D ATADIR direction);
[PreserveSig]
int DAdvise([In] ref FORMATETC pFormatetc, ADVF advf, IAdviseSink
adviseSink, out int connection);
void DUnadvise(int connection);
[PreserveSig]
int EnumDAdvise(out IEnumSTATDATA enumAdvise);
}-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bob Staheli" <st*********@gm ail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. Hi Nicholas,
Thanks for your reply.
However, System.Runtime. InteropServices .ComTypes.IData Object is only present in .Net 2.0. I am using .Net 1.1.
How can I do that in this case?
Bob
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:Ot******** ******@TK2MSFTN GP12.phx.gbl... Bob,
You can use the IDataObject in the System.Runtime. InteropServices .ComTypes namespace. It is the one you are looking for.
The DataObject class in the System.Windows. Forms namespace implements this as well.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bob Staheli" <st*********@gm ail.com> wrote in message news:%2******** *******@tk2msft ngp13.phx.gbl.. . The .Net DataObject class implements the COM/OLE IDataObject interface , so how do I get it.
I have tried this, but it does not work :
// Declare the COM/OLE IDataObject interface
[ComImport, Guid("0000010E-0000-0000-C000-000000000046"), InterfaceType(C omInterfaceType .InterfaceIsIUn known)] public interface IOleDataObject { [PreserveSig] int OleGetData(FORM ATETC pFormatetc, [Out] STGMEDIUM pMedium); [PreserveSig] int OleGetDataHere( FORMATETC pFormatetc, [In, Out] STGMEDIUM pMedium); [PreserveSig] int OleQueryGetData (FORMATETC pFormatetc); [PreserveSig] int OleGetCanonical FormatEtc(FORMA TETC pformatectIn, [Out] FORMATETC pformatetcOut); [PreserveSig] int OleSetData(FORM ATETC pFormatectIn, STGMEDIUM pmedium, int fRelease); [return: MarshalAs(Unman agedType.Interf ace)] IEnumFORMATETC OleEnumFormatEt c([In, MarshalAs(Unman agedType.U4)] int dwDirection); [PreserveSig] int OleDAdvise(FORM ATETC pFormatetc, [In, MarshalAs(Unman agedType.U4)] int advf, [In, MarshalAs(Unman agedType.Interf ace)] object pAdvSink, [Out, MarshalAs(Unman agedType.LPArra y)] int[] pdwConnection); [PreserveSig] int OleDUnadvise([In, MarshalAs(Unman agedType.U4)] int dwConnection); [PreserveSig] int OleEnumDAdvise([Out, MarshalAs(Unman agedType.LPArra y)] object[] ppenumAdvise); }
-------------------
DataObject data = new DataObject(); IOleDataObject ido = data as IOleDataObject --------------
When this is run, ido is null. I have also tried varrious other methods like using Marshal.GetIUnk nownForObject, Marshal.QueryIn terface, Marshal.GetType dObjectForIUnkn own, but none of the approaches work.
What am I doing wrong?
Thanks Bob
I tried your declaration but it didnt work..most wierd.
I should note that I changed IAdviseSink from the DAdvice method to an
[In, MarshalAs(Unman agedType.Interf ace)] object - does that make a
difference - i would think it is only the GUID applied to the interface that
matters...
Once again..i am using this code :
DataObject d = new DataObject();
IDataObject id = d as IDataObject;
id is still null.
I am out of ideas now.
Bob
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:%2******** *******@tk2msft ngp13.phx.gbl.. . Bob,
You should be able to declare this in your code, and it should work:
[ComImport, InterfaceType(C omInterfaceType .InterfaceIsIUn known), Guid("0000010E-0000-0000-C000-000000000046")] public interface IDataObject { void GetData([In] ref FORMATETC format, out STGMEDIUM medium); void GetDataHere([In] ref FORMATETC format, ref STGMEDIUM medium); [PreserveSig] int QueryGetData([In] ref FORMATETC format); [PreserveSig] int GetCanonicalFor matEtc([In] ref FORMATETC formatIn, out FORMATETC formatOut); void SetData([In] ref FORMATETC formatIn, [In] ref STGMEDIUM medium, [MarshalAs(Unman agedType.Bool)] bool release); IEnumFORMATETC EnumFormatEtc(D ATADIR direction); [PreserveSig] int DAdvise([In] ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection); void DUnadvise(int connection); [PreserveSig] int EnumDAdvise(out IEnumSTATDATA enumAdvise); }-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bob Staheli" <st*********@gm ail.com> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. .. Hi Nicholas,
Thanks for your reply.
However, System.Runtime. InteropServices .ComTypes.IData Object is only present in .Net 2.0. I am using .Net 1.1.
How can I do that in this case?
Bob
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:Ot******** ******@TK2MSFTN GP12.phx.gbl... Bob,
You can use the IDataObject in the System.Runtime. InteropServices .ComTypes namespace. It is the one you are looking for.
The DataObject class in the System.Windows. Forms namespace implements this as well.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bob Staheli" <st*********@gm ail.com> wrote in message news:%2******** *******@tk2msft ngp13.phx.gbl.. . The .Net DataObject class implements the COM/OLE IDataObject interface , so how do I get it.
I have tried this, but it does not work :
// Declare the COM/OLE IDataObject interface
[ComImport, Guid("0000010E-0000-0000-C000-000000000046"), InterfaceType(C omInterfaceType .InterfaceIsIUn known)] public interface IOleDataObject { [PreserveSig] int OleGetData(FORM ATETC pFormatetc, [Out] STGMEDIUM pMedium); [PreserveSig] int OleGetDataHere( FORMATETC pFormatetc, [In, Out] STGMEDIUM pMedium); [PreserveSig] int OleQueryGetData (FORMATETC pFormatetc); [PreserveSig] int OleGetCanonical FormatEtc(FORMA TETC pformatectIn, [Out] FORMATETC pformatetcOut); [PreserveSig] int OleSetData(FORM ATETC pFormatectIn, STGMEDIUM pmedium, int fRelease); [return: MarshalAs(Unman agedType.Interf ace)] IEnumFORMATETC OleEnumFormatEt c([In, MarshalAs(Unman agedType.U4)] int dwDirection); [PreserveSig] int OleDAdvise(FORM ATETC pFormatetc, [In, MarshalAs(Unman agedType.U4)] int advf, [In, MarshalAs(Unman agedType.Interf ace)] object pAdvSink, [Out, MarshalAs(Unman agedType.LPArra y)] int[] pdwConnection); [PreserveSig] int OleDUnadvise([In, MarshalAs(Unman agedType.U4)] int dwConnection); [PreserveSig] int OleEnumDAdvise([Out, MarshalAs(Unman agedType.LPArra y)] object[] ppenumAdvise); }
-------------------
DataObject data = new DataObject(); IOleDataObject ido = data as IOleDataObject --------------
When this is run, ido is null. I have also tried varrious other methods like using Marshal.GetIUnk nownForObject, Marshal.QueryIn terface, Marshal.GetType dObjectForIUnkn own, but none of the approaches work.
What am I doing wrong?
Thanks Bob
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Max Sandman |
last post by:
I need to import and export CSV files. Before I head off the create my
own CSV parser (got the link to Falafel's articles), is there a way to
use the DataObject class in this process? I don't want to waste time
figuring out what it does if it's really not going to help. It sounds
like (from the docs and from my search out here) that it's really meant
for drag & drop, clipboard, in-memory type transfers rather than from
CSV file to...
|
by: craigkenisston |
last post by:
Hi,
I will use an example to do a simplified description of my problem,
please don't laugh.
I just "believe" I would have to use either interface or abstract
classes, but I've not ever write an interface, though I know the basis
of
interfaces.
|
by: Naveen Mukkelli |
last post by:
Hi,
I've got 3 Network Interface Cards(NIC) in my PC. Lets say NIC1, NIC2, NIC3.
I have openend network connections in control panel and renamed them to
Network 1, Network 2, Network 3.
I'm trying to get these names( Network 1, Network 2, Network 3) by using C#.
When I tried using Win32_NetworkAdapterConfiguration class, I could get the
names of the actual hardware(NIC1, NIC2, NIC3) but not the renamed names
(Network 1, Network 2,...
|
by: Robin Tucker |
last post by:
I have an existing COM object that supports IDataObject (written in C++). I
want to use GetFormats and GetData on this object in VB.NET, but I blooming
well can't.
If I write:
Dim theObject As IDataObject
theObject = GetObject ( "C:\GAS.TGW" )
|
by: Hei |
last post by:
Hi
is vb.net' "interface" is sound like C++ "abstract class" ?
Hei
| |
by: Rodolfo |
last post by:
Hi all....
I have to develop a class application but I must use a COM+ DLL (vb6)
intalled in a remote COM+ server.
The proxy application is already installed in IIS server but I can't use any
mtehod of this dll.
The following error is occuring: "QueryInterface for interface DLL.Class
failed"
I've been testing this code in an ASPX page with the property aspCompat=True
|
by: Mark Wilden |
last post by:
Take a class, RateTableProductCode. It needs to share implementation with
other classes, so the common code is placed in a ProductCode class, from
which it derives. There needs to be an IRateTableProductCode interface so
that objects can be mocked for testing. That interface also has a common
interface which is shared with other interfaces, and that goes in
IProductCode. This all makes sense to me, but I just have a nagging feeling
that...
|
by: Ezmeralda |
last post by:
Hello,
I need to an TCP/IP Interface for communication with an embedded
device.
Since I have two different design ideas in mind, I am wondering
whether
you could give me some hints to decide:
Requirements:
- Interface should be used for company internal purposes/software but
|
by: Adrian |
last post by:
In the following code example I am trying to create a generic interface for a bunch of objects. Each concrete type is stored in its own container and the a container of pointer's to base is used so I can access all at once.
I created a specialization of the template for Fruit *'s so that it returns a reference and the code looks the same as when accessing a concrete type.
I've managed to get everything working so far except accessing all...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |