Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / July 2006

Tip: Looking for answers? Try searching our database.

IDataObject GetData - "The parameter is incorrect"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel Halan - 05 Jul 2006 19:26 GMT
Hello,

Im trying to fetch a Drop-event, and everything goes fine until I call the
"GetData" method.

Ive tried both to catch the drop with defining FormatEtc to a CF_HDROP and
iterating Formats with "EnumFormatEtc" both returns same error...

Im guessing it doesnt like the input of FormatEtc or StgMedium params but
have compared my input with other working C++ code and I cant see any diff.

here are my definitions:

[ComVisible(false), StructLayout(LayoutKind.Sequential)]
public struct StgMedium {
 [MarshalAs(UnmanagedType.U4)]
 public StorageMedia tymed;
 public IntPtr p;
 [MarshalAs(UnmanagedType.IUnknown)]
 public IntPtr pUnkForRelease;
}

[ComVisible(false), StructLayout(LayoutKind.Sequential)]
public struct FormatEtc {
 [MarshalAs(UnmanagedType.I4)]
 public int cfFormat;
 public IntPtr ptd;
 [MarshalAs(UnmanagedType.U4)]
 public DeviceAspects dwAspect;
 [MarshalAs(UnmanagedType.I4)]
 public int lindex;
 [MarshalAs(UnmanagedType.U4)]
 public StorageMedia tymed;
}

and the IDataObject::GetData method:

[PreserveSig]
int GetData([In]ref FormatEtc pformatetcIn, [In, Out] ref StgMedium
pmedium);

and one of the calls:

----------------------

FormatEtc formatetc = new FormatEtc();
formatetc.cfFormat = (int)Shell32.CF_HDROP;
formatetc.ptd = IntPtr.Zero;
formatetc.dwAspect = DeviceAspects.Content;
formatetc.lindex = -1;
formatetc.tymed = StorageMedia.HGlobal;

StgMedium stgMedium = new StgMedium();
pDataObj.GetData(ref formatetc, ref stgMedium);

Anyone?

//DH
Michael Phillips, Jr. - 06 Jul 2006 14:47 GMT
> [PreserveSig]
> int GetData([In]ref FormatEtc pformatetcIn, [In, Out] ref StgMedium
> pmedium);

StgMedium is an Out parameter.  It is allocated by the callee not the
caller.

Try this:

[PreserveSig]
int GetData([In]ref FormatEtc pformatetcIn, [Out] out StgMedium  pmedium);

StgMedium stgMedium;
pDataObj.GetData(ref formatetc, out stgMedium);

> Hello,
>
[quoted text clipped - 55 lines]
>
> //DH

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.