15,473
社区成员




//DllPlus.h
#ifdef Dll_API
#else
#define Dll_API _declspec(dllimport)
#endif
Dll_API int add(int a,int b);
Dll_API int subtract(int a,int b);
class Dll_API PointObject
{
public:
void output(int x,int y);
};
//DllPlus.cpp
#define Dll_API _declspec(dllexport)
#include "DllPlus.h"
#include <Windows.h>
#include <iostream>
int add(int x,int y)
{
return x + y;
}
int subtract(int x,int y)
{
return x - y;
}
//在窗口上输出一字符串。
void output(int x,int y)
{
HWND hwnd = GetForegroundWindow();
HDC hdc = GetDC(hwnd);
char buf[20];
memset(buf,0,20);
sprintf(buf,"x=%d,y=%d",x,y);
TextOut(hdc,0,0,buf,strlen(buf));
ReleaseDC(hwnd,hdc);
}
#include "stdafx.h"
#include "DllTest.h"
#include "DllTestDlg.h"
#include "afxdialogex.h"
#include "..\..\DllPlus\DllPlus\DllPlus.h"
...
void CDllTestDlg::OnBnClickedButtonClass()
{
PointObject pt;
pt.output(3,5);
}