[WIKI] Creating and Linking Dlls -- Reloaded

Hi XenoEgger,

Hhahaha, I made that wiki loooooong time ago, let me help you a little bit, start by creating an empty c++ project Win32 Console Command, choose DLL and empty Project

like this:

this is my H:



#ifndef __MAIN_H__
#define __MAIN_H__
#pragma once
#include <windows.h>
/*  To use this exported function of dll, include this header
*  in your project.
*/
#define DLL_EXPORT __declspec(dllexport)
#ifdef __cplusplus
extern "C"
{
#endif
	float DLL_EXPORT getCircleArea(float radius);
#ifdef __cplusplus
}
#endif
#endif // __MAIN_H__


and the cpp:



#pragma once
#include "main.h"

// a sample exported function
float DLL_EXPORT getCircleArea(float radius)
{
	return 3.1416f * (radius * radius);
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	switch (fdwReason)
	{
	case DLL_PROCESS_ATTACH:
		// attach to process
		// return FALSE to fail DLL load
		break;
	case DLL_PROCESS_DETACH:
		// detach from process
		break;
	case DLL_THREAD_ATTACH:
		// attach to thread
		break;
	case DLL_THREAD_DETACH:
		// detach from thread
		break;
	}
	return TRUE; // successful
}


following the same example provided
BTW there is a lot of info about how to create DLLs for c++ or c#, see examples from web

Cheers