15,473
社区成员




HMODULE hDll = ::LoadLibraryEx(_T("F:\\B.dll"), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
// DllB.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include <stdio.h>
extern "C" __declspec( dllexport ) void __cdecl funB()
{
printf("%s was called\n", __FUNCDNAME__);
}
// DllA.cpp : 定义 DLL 应用程序的导出函数。
#include "stdafx.h"
#include <stdio.h>
#pragma comment(lib, "../debug/DllB.lib")
extern "C" void __cdecl funB();
extern "C" __declspec( dllexport ) void __cdecl funA()
{
printf("%s was called\n", __FUNCDNAME__);
funB();
}
// Win32Dll.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <windows.h>
#include <crtdbg.h>
int _tmain(int argc, _TCHAR* argv[])
{
HMODULE hDll = LoadLibrary(_T("d:\\temp\\DllA.dll")); //_T("DllA.dll")
if(hDll != NULL)
{
typedef void (__cdecl *FUNA)();
FUNA pf = (FUNA)GetProcAddress(hDll, "funA");
if(pf)
{
pf();
}
FreeLibrary(hDll);
}
else
{
printf("LoadLibrary failed %u\n", GetLastError());
_ASSERT(0);
}
return 0;
}