#define IESCOMMINTERFACE
#ifdef WIN32
#ifdef IESCOMMINTERFACE
#define IESCOMMINTERFACE_API __declspec(dllexport)
#else
#define IESCOMMINTERFACE_API __declspec(dllimport)
#endif
#else
#define IESCOMMINTERFACE_API
#endifclass IESCOMMINTERFACE_API CSMTP
{
public:
BOOL PL_SendMail(CString strSMTP);
}我已在dll里声明以上导出类,并生成dll,现在有问题:
(1) 导出类这样声明对么?还需要加什么文件或语句么?
(2) 在一个.exe里, HINSTANCE dllinstance;
dllinstance=::LoadLibrary("D:\\usesmtp\\smtpdll.dll");
已经导入已成功; 但a加入CSMTP kkk; 为么错? 怎么用导出类?
#ifdef WIN32
#ifdef IESCOMMINTERFACE
#define IESCOMMINTERFACE_API __declspec(dllexport)
#else
#define IESCOMMINTERFACE_API __declspec(dllimport)
#endif
#else
#define IESCOMMINTERFACE_API
#endifclass IESCOMMINTERFACE_API CSMTP
{
public:
BOOL PL_SendMail(CString strSMTP);
}我已在dll里声明以上导出类,并生成dll,现在有问题:
(1) 导出类这样声明对么?还需要加什么文件或语句么?
(2) 在一个.exe里, HINSTANCE dllinstance;
dllinstance=::LoadLibrary("D:\\usesmtp\\smtpdll.dll");
已经导入已成功; 但a加入CSMTP kkk; 为么错? 怎么用导出类?
D:\usmtpdllDlg.cpp(174) : error C2065: 'CSMTP' : undeclared identifier
D:\usmtpdllDlg.cpp(174) : error C2146: syntax error : missing ';' before identifier 'kkk'
D:\usmtpdllDlg.cpp(174) : error C2065: 'kkk' : undeclared identifier怎么还是没定义啊?
2、在#define IESCOMMINTERFACE_API __declspec(dllimport)的下面一行加入:
#pragma comment(lib, "×××.lib"); // ×××.LIB为你编译生成的lib文件名
3、Copy ×××.dll/×××.lib/×××.h到您的EXE工程目录
4、在EXE的stdafx.h中加入:
#include ×××.h
然后您就可以使用CSMTP类了PS:以上为很多产品使用的方法
这是什么意思?
warning C4091: '__declspec(dllimport ) ' : ignored on left of 'class CSMTP' when no variable is declared
error LNK2001: unresolved external symbol "public:....
在工程的文件夹里面,把你dll.h和dll.lib文件加进去,然后编译.你忘记加入了dll.h啦