By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,012 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

PInvoke Custom Marshaling a Value type (Boxing)

P: n/a
I am trying to do some P/Invoke custom marshaling and am looking for a
little help on custom marshaling a value type.

I am working based on Kate Gregory's "Arranging Custom Marshaling With
P/Invoke", which is unfortunately in C++ with managed extensions; I am
working in C#.

As with Kate's example I want to marshal from a System.DateTime to a
proprietary format. However I cannot figure out how to tell the system
to box the DateTime. Can anyone tell me the C# equivalent of __box?

I guess what I want is the C# equivalent of this:

[DllImport("legacy")] bool MyFunc ([In,
MarshalAs(UnmanagedType::CustomMarshaler,
MarshalTypeRef=__typeof(MYDATETYPE_CustomMarshaler ))]
__box DateTime* time);

TIA

Bill Medland

Mar 16 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Bill Medland" <bi*********@mercuryspeed.com> wrote in message
news:11*********************@i39g2000cwa.googlegro ups.com...
I am trying to do some P/Invoke custom marshaling and am looking for a
little help on custom marshaling a value type.

I am working based on Kate Gregory's "Arranging Custom Marshaling With
P/Invoke", which is unfortunately in C++ with managed extensions; I am
working in C#.

As with Kate's example I want to marshal from a System.DateTime to a
proprietary format. However I cannot figure out how to tell the system
to box the DateTime. Can anyone tell me the C# equivalent of __box?

I guess what I want is the C# equivalent of this:

[DllImport("legacy")] bool MyFunc ([In,
MarshalAs(UnmanagedType::CustomMarshaler,
MarshalTypeRef=__typeof(MYDATETYPE_CustomMarshaler ))]
__box DateTime* time);


Can't you do this another way, such as creating a structure to pass in or
passing in an IntPtr instead?

Michael
Mar 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.