dll转发

时间:2021-08-21 08:18:50   收藏:0   阅读:15
// Dll1.cpp : 定义 DLL 的导出函数。
//

#include "pch.h"
#include "framework.h"
#include "Dll1.h"


#pragma comment(linker,"/EXPORT:Add=Dll2.Add")
// Dll2.cpp : 定义 DLL 的导出函数。
//

#include "pch.h"
#include "framework.h"
#include "Dll2.h"


int Add(int a, int b)
{

    return (a + b);
}
#include<iostream>
#include<Windows.h>
using namespace std;

typedef int(*FUNC)(int a, int b);
int main()
{
    HMODULE hModule = LoadLibraryA("Dll1.dll");
    FUNC mAdd = (FUNC)GetProcAddress(hModule, "Add");
    int result = mAdd(1, 2);
    cout << result << endl;
    cin.get();

    return 0;
}

 

原文:https://www.cnblogs.com/iGhost/p/15168340.html

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!