Click here to Skip to main content
15,895,774 members
Articles / Desktop Programming / Win32

Mixing .NET and native code

Rate me:
Please Sign up or sign in to vote.
4.85/5 (49 votes)
7 Apr 2014CPOL9 min read 164.1K   7.2K   140  
A first approach to mixing .NET and native code, using the C++/CLI gateway.
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently

#pragma once

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER                // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501         // Change this to the appropriate value to target other versions of Windows.
#endif

#ifndef _WIN32_WINNT          // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501   // Change this to the appropriate value to target other versions of Windows.
#endif						

#ifndef _WIN32_WINDOWS        // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE             // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600      // Change this to the appropriate value to target other versions of IE.
#endif

#define WIN32_LEAN_AND_MEAN   // Exclude rarely-used stuff from Windows headers
// Windows�header files:
#include <windows.h>


#ifdef _DEBUG
   #define _CRTDBG_MAP_ALLOC
   #include <stdlib.h>
   #include <crtdbg.h>

   #ifndef DBG_NEW
      #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
      #define new DBG_NEW
   #endif
#endif


#include "..\AdR.Samples.CLRCallingNative.NativeDLL\AdR.Samples.CLRCallingNative.NativeDLL.h"

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
France France
I started working in 1991 as an engineer. My pecialization: development in robotics.

After two years in this job, I began a new career leaving robotics, and coming to standard development as C++ expert.

This enabled me to diversify my knowledge by putting one foot on the side of the systems. Then began my double competence.

In 2000 I started a new job as consultant. Many experiences came with that new job, continuing with both development and systems subjects.

I reinforced my knowledge in technical architectures, IT security, and IT production management.

2011: a new experience. I founded the company Net-InB, a computer services company specialized in the fields of infrastructures, systems and software.

Now I am both technical and software architect specialized in Microsoft products and technologies.

Comments and Discussions