随笔 - 34, 文章 - 3, 评论 - 10, 引用 - 0
数据加载中……

调用dll

#include "ICommonDll.h"

typedef BOOL (*ProcType)(VOID **) ;

void CTestDllDlg::OnButton1()
{
    // TODO: Add your control notification handler code here
    HMODULE hDll = LoadLibrary( "E:\\DLl_House\\Common\\Debug\\Common.dll" ) ;

    if ( hDll == NULL )
    {
        ASSERT ( "load dll faile" == NULL ) ;
        return ;
    }

    ProcType pt = (ProcType)GetProcAddress( hDll, "QueryInterface" ) ;
    if ( pt == NULL )
    {
        ASSERT ( "point QueryInterface faile " == NULL ) ;
        return ;
    }

    ICommonDll * pI = NULL ;
    BOOL bOK = pt( (void**)&pI ) ;
    if ( pI == NULL )         
    {
        ASSERT ( "" == NULL ) ;
        return ;
    }

    CString str ;
    pI->InitInstance() ;
    str = pI->GetCurTime() ;
    pI->IsFileExist( "E:\\DLl_House\\Common\\ICommonDll.h" ) ;
    HANDLE hFile = NULL ;
    pI->PrintLog( hFile, "sdfsdf" ) ;
    pI->GetAppPath() ;
    pI->Release() ;
    pI = NULL ;
    FreeLibrary( hDll ) ;
}



typedef BOOL (*ProcType)(VOID **) ;

BOOL CBus::LoadDll( CString strDllName, VOID** ppData  )
{
    m_hDll = LoadLibrary( strDllName ) ;
   
    if ( m_hDll == NULL )
    {
        ASSERT ( "load dll faile" == NULL ) ;
        return FALSE;
    }
   
    ProcType pt = (ProcType)GetProcAddress( m_hDll, "QueryInterface" ) ;
    if ( pt == NULL )
    {
        ASSERT ( "point QueryInterface faile " == NULL ) ;
        return FALSE;
    }

    BOOL bOK = pt( (void**)ppData ) ;
   
    if ( ppData == NULL )        
    {
        ASSERT ( "" == NULL ) ;
        return FALSE;
    }
    return TRUE ;
}

posted on 2009-10-28 22:08 wsy6634 阅读(182) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理