Click here to Skip to main content
15,884,741 members
Articles / Mobile Apps

HOWTO: Combine Managed and Unmanaged Projects into a Single Visual Studio Solution

Rate me:
Please Sign up or sign in to vote.
4.28/5 (26 votes)
8 Apr 2004CPOL18 min read 145.9K   343   54  
This article describes how to combine managed and unmanaged projects into a single Visual Studio .NET solution.
// Unmanaged.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "Unmanaged.h"

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
		case DLL_THREAD_ATTACH:
		case DLL_THREAD_DETACH:
		case DLL_PROCESS_DETACH:
			break;
    }
    return TRUE;
}


// This is an example of an exported variable
UNMANAGED_API int nUnmanaged=0;

// This is an example of an exported function.
UNMANAGED_API int fnUnmanaged(LPCTSTR lpszMessage)
{
	return MessageBox(NULL, lpszMessage, _T("Unmanaged"), MB_OK | MB_ICONEXCLAMATION);
}

// This is the constructor of a class that has been exported.
// see Unmanaged.h for the class definition
CUnmanaged::CUnmanaged()
{ 
	return; 
}

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
Web Developer
United Kingdom United Kingdom
I'm an old MFC lag, currently wrestling with the niceties of C# and Pocket PCs.

Comments and Discussions