473,659 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the COM IDataObject interface from the DataObject class

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
Jan 21 '06 #1
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

Jan 21 '06 #2
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


Jan 21 '06 #3
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



Jan 21 '06 #4
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



Jan 22 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1984
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...
12
1866
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.
1
2932
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,...
1
1689
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" )
4
1249
by: Hei | last post by:
Hi is vb.net' "interface" is sound like C++ "abstract class" ? Hei
0
1087
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
6
1630
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...
1
3749
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
3
1457
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...
0
8428
marktang
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...
0
8851
Oralloy
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...
0
8751
jinu1996
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...
1
8535
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,...
1
6181
isladogs
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...
0
5650
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();...
0
4176
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...
0
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2757
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.