15,472
社区成员
发帖
与我相关
我的任务
分享
#pragma once
#ifndef testMfcDll_H
#define testMfcDll_H
class __declspec(dllexport) testMfcDll;
class testMfcDll
{
public:
testMfcDll(){};
virtual ~testMfcDll(){};
void sayHello();
CString &sayHelloWord();
void sayWhat(CString &);
CString strHello;
};
#endif
// testMfcDll.cpp : 定义 DLL 的初始化例程。
//
#include "stdafx.h"
#include "testMfcDll.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
void testMfcDll::sayHello()
{
//这是win的MessageBox
MessageBox(NULL, _T("hello"), _T("提示"), MB_OK);
}
CString& testMfcDll::sayHelloWord()
{
strHello = _T("hello world");
return strHello;
}
void testMfcDll::sayWhat(CString &str)
{
if(str == _T("hello"))
{
str = _T("get way");
MessageBox(NULL, _T("get way"), _T("提示"), MB_OK);
}else
{
MessageBox(NULL, _T("hello"), _T("提示"), MB_OK);
}
}
testMfcDll test;
test.sayHello();//只调用这个可以正常运行
CString str = _T("hello");
str = test.sayHelloWord();//这个编译不过
test.sayWhat(str);//这个编译不过
MessageBox(str);