动态调用win32 dll

来源:互联网 发布:如何关闭udp端口 编辑:程序博客网 时间:2024/05/22 17:14
typedef int (*getradardata)(const char *, float fHeight, char *, const char *);
typedef int (*getradardataLevel)(const char *, int iLevel, char *, const char *);
typedef int (*add)(int,int);


int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
    int nRetCode = 0;

    // initialize MFC and print and error on failure
    if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
    {
        // TODO: change error code to suit your needs
        _tprintf(_T("Fatal Error: MFC initialization failed\n"));
        nRetCode = 1;
    }
    else
    {
        // TODO: code your application's behavior here.
        //Factory * pFactory = new ConcreteFactory();
        //pFactory->CreateProduct();

        //delete pFactory;   

        {

            HMODULE hdll = LoadLibrary(_T("PictureFactoryPlugin.dll"));

            getradardata func = (getradardata)GetProcAddress(hdll, "GetDataByHeight");
            getradardataLevel funcLevel = (getradardataLevel)GetProcAddress(hdll, "GetDataByLevel");
            add funcAdd = (add)GetProcAddress(hdll, "addtest");

            char data[460*460*4];
            func("CAP.bin.bz2", 5.0, data, 0);
            int i = funcAdd(2, 4);
            return 0;
        }




    }

    system("PAUSE");
    return nRetCode;
}


原创粉丝点击