Thursday, November 22, 2007

From Jason Olson.

//code starts here

#pragma once
#include
<msclr\marshal.h>
#include <msclr\marshal_windows.h>
namespace msclr {
namespace interop {

////////////////////////////////////////////////////////////////////
// File I/O Conversions (constants from System::IO)
///////////////////////////////////////////////////////////////////

template<>
inline DWORD marshal_as<DWORD, System::IO::FileMode>(const System::IO::FileMode& from) {

if (from != System::IO::FileMode::Append)
   
return (DWORD)from;
else
   
return (DWORD)System::IO::FileMode::OpenOrCreate;

}

template<>
inline DWORD marshal_as<DWORD, System::IO::FileAccess>(const System::IO::FileAccess& from) {
if (from == System::IO::FileAccess::Read)
   
return GENERIC_READ;
else
   
return GENERIC_WRITE;

}

template<>
inline DWORD marshal_as<DWORD, System::IO::FileShare>(const System::IO::FileShare& from) {
   
return (DWORD)from;

}

}

}

//code ends here

Nice and simple.

Kate

posted on 11/22/2007 8:35:35 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]

Related Posts:
HFONT and System::Drawing::Font
RECT, CRect, and System::Drawing::Rectangle
_GUID and System::Guid