LoadLibraryEx使用

#include "stdafx.h"
#include 
#include 

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;
}

你可能感兴趣的:(mfc,c++,算法,开发语言)