#include "stdafx.h"
#include <Windows.h>
#include <iostream>
typedef int (*fun)(void);
int main()
{
std::cout << "helll word" << std::endl;
HMODULE h = LoadLibraryEx(_T("adddll.dll"), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (h) {
std::cout << "helll word1" << std::endl;
fun cFun_add = (fun)GetProcAddress(h, ("fnadddll"));
if (NULL != cFun_add) {
printf("%d\n", cFun_add());
}
else {
printf("get cfun_Add fail %d\n",GetLastError());
}
FreeLibrary(h);
}
getchar();
return 0;
}
库
extern "C" __declspec(dllexport) int fnadddll(void)
{
return 10086;
}