C++ dll を動的にロードしようとしました。最初に「LoadLibrary」関数を使用して dll をロードし、ハンドルを正しく取得しています。その後、「GetProcAddress」を使用してDLLファイル関数の関数ポインタを取得しようとしましたが、NULLを返しています。私の DLL コードとテスト アプリケーション コードを見つけて、コードのどこが間違っているか教えてください。
ダミー2.h
namespace newer
{
class dllclass
{
public:
static __declspec(dllexport) int run(int a,int b);
};
}
ダミー2.cpp
#include <iostream>
using namespace std;
#include "dummy2.h"
namespace newer
{
int dllclass::run(int a,int b)
{
return a+b;
}
}
ダミー1.cpp
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;
typedef int (*Addition)(int,int);
int _tmain(int argc, _TCHAR* argv[])
{
Addition add;
HINSTANCE hDLL;
hDLL = LoadLibrary(TEXT("Dummy2.dll"));
add = (Addition)GetProcAddress(hDLL, "run");
getchar();
return 0;
}
上記のコードを参照して、私を導いてください。