dll文件只能在MFC框架下制作吗?在API下能做吗?

来源:百度知道 编辑:UC知道 时间:2024/09/28 09:37:42
如题,如果我有一个程序是API编写的,我想把它做成dll文件以备其它程序调用,可我发现一般只有MFC框架下可做dll文件,那怎样才能实现我的想法?前辈指点一下,谢谢!

你可以在选工程时选:Win32 Dynamic-Link Library

下面有一个例子:

///////////////
//DLL1.h
///////////////
#ifdef DLL1_API
#else
#define DLL1_API extern "C" _declspec(dllimport)
#endif

DLL1_API int _stdcall add(int a,int b);
DLL1_API int _stdcall subtract(int a,int b);

class DLL1_API Point
{
public:
void output(int x,int y);
void test();
};

////////////////////////
//DLL1.cpp
//////////////////////
#define DLL1_API extern "C" _declspec(dllexport)
#include "Dll1.h"

#include <Windows.h>
#include <stdio.h>

int _stdcall add(int a,int b)
{
return a+b;
}

int _stdcall subtract(int a,int b)
{
return a-b;
}

void Point::output(int x,int y)
{
HWND hwnd=GetForegroundWindow();
HDC hdc=GetDC(hwnd);
char buf[20];
memset(buf,0,20);