views:

887

answers:

2

Hi all,

I have an older library that uses COleDateTime as a return type in a C++ MFC Dll. When I do a PInvoke, can I marshal that with confidence to a DateTime object? Or should I do something wacky, like convert the COleDateTime into the number of ticks since 1970, and then convert those ticks back to a DateTime object in the C# calling project?

Thanks!

+1  A: 

Use DateTime.FromOADate().

Hans Passant
+2  A: 

You can return a double, by accessing the m_dt member. Then, you would pass that to the static FromOADate method on the DateTime structure to convert that to a DateTime structure.

casperOne