Dll 的创建 和调用

来源:互联网 发布:js判断数字是否是整数 编辑:程序博客网 时间:2024/05/19 13:15

Dll的源码

#include <stdio.h>void test(){    printf("Hello world!\n");}int sum(int a,int b){    return (a + b);}

Dll-def的源码

LIBRARY EXPORTStestsum

调用Dll的主程序源码

#include <Windows.h>#include <stdio.h>typedef int(*Sum)(int,int);void main() {    HMODULE HDLL = LoadLibrary("Project1.dll");    FARPROC test = GetProcAddress(HDLL, "test");    test();    Sum sum = (Sum)GetProcAddress(HDLL, "sum");    printf("%d\n",sum(3,5));    system("pause");    FreeLibrary(HDLL);}

运行结果

0 0
原创粉丝点击