zoukankan      html  css  js  c++  java
  • vc 导出函数/调用

    loader(exe):

    #include "stdafx.h"
    #include <Windows.h>
    #include <stdio.h>
    #define Loaddll_API __declspec(dllexport)
    extern "C" Loaddll_API int _stdcall testloader(void);
    #pragma comment(lib,"Loaddll")
    int main(int argc,char* argv[])
    {
        testloader(); //隐式调用
    
        //显示调用
        typedef  int(_stdcall *Fun)(void);
        HMODULE hmod = LoadLibraryA("Loaddll.dll");
        Fun testFun = GetProcAddress(hmod,"testloader");
        testFun();
    
    
        system("pause");
        return 0;
    }

    dll:Loaddll

    #include "stdafx.h"
    #include <Windows.h>
    #include <stdio.h>
    #define Loaddll_API __declspec(dllexport)
    extern "C"  Loaddll_API int _stdcall testloader(void);
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
                         )
    {
        switch (ul_reason_for_call)
        {
        case DLL_PROCESS_ATTACH:
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            break;
        }
        return TRUE;
    }
    
    extern "C" int _stdcall testloader(void)
    {
        MessageBoxA(NULL,"loader dll","Title",MB_OK);
        printf("Hello word,this is a export dll functions
    ");
        return 0;
    }

    添加一个.def模块定义文件。

    LIBRARY "Loaddll"
    
    EXPORTS
    
    testloader @ 1

  • 相关阅读:
    Spring
    Spring
    Spring
    Spring
    JS 脱敏通用方法
    JS 实用技巧记录
    多快?好省!
    实战 | 如何使用微搭低代码实现按条件过滤数据
    2021腾讯数字生态大会落地武汉,微搭低代码专场等你来
    实战 | 如何使用微信云托管部署flask项目
  • 原文地址:https://www.cnblogs.com/killbit/p/5324150.html
Copyright © 2011-2022 走看看