在VS2010下怎样调用 VS2010生成的dll?
VC2010? dll
//在VS2010下建立了一个EmailDll的动态库工程 (Visual C++ -- Win32 -- Win32 项目 -- dll)
/*extern "C"*/ _declspec(dllexport) int _stdcall SendData( string sData )
{
int iReturn;
//Sending data...
return iReturn;
}
// MyTest.cpp : 定义控制台应用程序的入口点。
// 在VS2010下建立了一个MyTest工程,去调用 EmailDll.dll
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <Windows.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string sData = "TTTTTTTTT";
typedef int (_stdcall *pSendData)( string sData );
pSendData SendData = NULL;
HMODULE g_hDll = ::LoadLibrary( _T("EmailDll.dll") ); //g_hDll值为空
SendData= (pSendData)GetProcAddress(g_hDll, "SendData"); //值为空,没有获得dll里面的函数地址
SendData( sData );
FreeLibrary(g_hDll);
return 0;
}