在VS2010停怎样调用 VS2010生成的dll
在VS2010下怎样调用 VS2010生成的dll?
------解决方案--------------------
1、将dll工程导出.lib,
2、在导入的工程中引入.lib、include dll's .h
3、在导入的工程中调用函数,编译
------解决方案--------------------
1.不要用string做参数,这个不标准也不通用,用char*
2. g_hDll值还是为空 表示没有加载到动态库,使用全路径试试,如:C:\\data\\EmailDll.dll
------解决方案--------------------
/*extern "C"*/ 不能注释吧
------解决方案--------------------
http://blog.****.net/dodomouse/article/details/12843821
前段时间搞得,嘿嘿
//在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;
}
VC2010
dll
------解决方案--------------------
1、将dll工程导出.lib,
2、在导入的工程中引入.lib、include dll's .h
3、在导入的工程中调用函数,编译
------解决方案--------------------
1.不要用string做参数,这个不标准也不通用,用char*
2. g_hDll值还是为空 表示没有加载到动态库,使用全路径试试,如:C:\\data\\EmailDll.dll
------解决方案--------------------
/*extern "C"*/ 不能注释吧
------解决方案--------------------
http://blog.****.net/dodomouse/article/details/12843821
前段时间搞得,嘿嘿