如何显示调用DLL中的函数???
函数带参数的又如何调用???

解决方案 »

  1.   

    static HINSTANCE hinstDLL2; 
    typedef BOOL (CALLBACK *inshook)(); 
    inshook instkbhook; hinstDLL2 = LoadLibrary((LPCTSTR) "GetDBInfo.dll");//显示调用
    if( hinstDLL2 == NULL )
    {
    MessageBox( "不能取得载入模块。文件GetDBInfo.dll没有找到。" );
    return;
    } instkbhook = (inshook)GetProcAddress(hinstDLL2, "TestDB"); 
    if( instkbhook != NULL )
    {
    if (!instkbhook())
    MessageBox( "不能连接到数据源,请检查数据源是否连接正常!" );
    //CTestView::SetWindowText(instkbhook());
    return;
    }
    else
    MessageBox( "没有找到函数地址!文件GetDBInfo.dll受到破坏。" );
    FreeLibrary(hinstDLL2);//释放动态链接库
      

  2.   

    如果动态库中的导出函数比如:
    void A(int i);
    那这句
    typedef BOOL (CALLBACK *inshook)(); 
    就改为
    typedef BOOL (CALLBACK *inshook)(int); 
    有两个参数的话也一样
    void A(int i, char p);
    typedef BOOL (CALLBACK *inshook)(int, char); 
      

  3.   

    typedef void (*CheckBalance)(SEND_FILE_LIST *pSendFileList); 
    CheckBalance pSend;
    SEND_FILE_LIST *pSendFileList = new SEND_FILE_LIST;
    HINSTANCE  hInstDLL= LoadLibrary((LPCTSTR)"balanceconfig.dll");
    if(hInstDLL)
    {
       pSend = (CheckBalance)GetProcAddress(hInstDLL, "CheckBalanceState"); 
       pSend(pSendFileList);
    }
    FreeLibrary(hInstDLL);
    参数是指,不要带CALLBACK,其它的跟newsark(公子) 的差不多!