As the problem is trivial for C# vs C++/CLI, I can assume that you are talking about native (unmanaged) C++ project.
As
System.DataTime
is a CLI structure, you cannot use its reference in unmanaged code. You have to use Windows date-time structure, pass it to managed code, and convert it to
System.DataTime
on the CLI side (in C#).
In particular, you can use Windows
FILETIME
:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724284%28v=vs.85%29.aspx[
^].
As you can see, this is a 64-bit integer value composed as a record of two 32-bit values. You can pass it to C#, and convert to one 64-bit value (do you know how?). It will give you the time in 100-ns intervals. Use this value to initialize
DataTime
value using one of these constructors:
http://msdn.microsoft.com/en-us/library/z2xf7zzk.aspx[
^],
http://msdn.microsoft.com/en-us/library/w0d47c9c.aspx[
^].
A more advanced way would be using customizing parameter
marshalling, which is still done on the CLI side (C#) and would essentially do the same. To get an idea, please see:
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.icustommarshaler.aspx[
^].
I hope you know that you can import native C++ function using P/Invoke and know how. If not, please refer to:
http://en.wikipedia.org/wiki/Platform_Invocation_Services[
^],
http://msdn.microsoft.com/library/en-us/vcmxspec/html/vcmg_PlatformInvocationServices.asp[
^].
This CodeProject article can also be useful:
Essential P/Invoke[
^].
—SA