使用C++调用dll,方便调试

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "tchar.h"
#include<Windows.h>  
#include <iostream>
typedef void(*funcptr)(int,int,int,int,int);
int main()
{
    using namespace std;
    const char* dllName = "";
    const char* funcName = "";
    HMODULE hDLL = LoadLibrary(_T(dllName));
    if (hDLL != NULL)
    {
        funcptr func = (funcptr)GetProcAddress(hDLL, funcName);
        if (func != NULL)
        {
            (*func)(1,1,1,1,1);
        }
        else
        {
            std::cout << "Cannot Find Function " << funcName << std::endl;
        }
    }
    else
    {
        std::cout << "Cannot Find " << dllName << std::endl;
    }
    getchar();
    return 0;
}