예제 #1
0
HRESULT CBkBackupProxy::Initialize()
{
    HRESULT hr = E_FAIL;

    WinMod::CWinPath    Path;

    //
    hr = CAppPath::Instance().GetLeidianAppPath( Path.m_strPath ); 
    if ( SUCCEEDED(hr) )
    {   
        Path.Append( BACKUP_DLL_NAME );
        hr = _LoadBkBackup( Path.m_strPath );
        if ( SUCCEEDED(hr) )
        {
            //成功返回
            return hr;
        }
    }
    //执行到这说名之前失败。
    hr = Path.GetModuleFileName(NULL);
    if ( SUCCEEDED(hr) )
    {
        Path.RemoveFileSpec();
        Path.Append( BACKUP_DLL_NAME );
        hr = _LoadBkBackup( Path.m_strPath );
        if ( SUCCEEDED(hr) )
        {
            //成功返回
            return hr;
        }
    }
    //
    return hr;
}
예제 #2
0
HRESULT CZlib::InitZlib()
{
#if defined(USE_STATIC_ZLIB)
	zlib_compress       = compress;
	zlib_compress2      = compress2;
	zlib_uncompress     = uncompress;
	zlib_inflate        = inflate;
	zlib_inflateEnd     = inflateEnd;
	zlib_inflateInit_   = inflateInit_;
	zlib_inflateInit2_  = inflateInit2_;
	return S_OK;
#else
	HRESULT             hr = S_OK;
	WinMod::CWinPath    modpath;

    hr = CAppPath::Instance().GetLeidianAppPath( modpath.m_strPath );
    if ( FAILED( hr ) )
    {
        return hr;
    }

    modpath.Append( ZLIB_FILE_NAME );

    m_lock.Lock();
    if ( NULL == g_hZlib )
    {
        g_hZlib = LoadLibrary( modpath );
        if ( NULL == g_hZlib )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_compress = ( PFN_compress )GetProcAddress( g_hZlib, FN_compress );
        if ( NULL == zlib_compress )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_compress2 = ( PFN_compress2 )GetProcAddress( g_hZlib, FN_compress2 );
        if ( NULL == zlib_compress )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_uncompress = ( PFN_uncompress )GetProcAddress( g_hZlib, FN_uncompress );
        if ( NULL == zlib_uncompress )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_inflate = ( PFN_inflate )GetProcAddress( g_hZlib, FN_inflate );
        if ( NULL == zlib_inflate )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_inflateEnd = ( PFN_inflateEnd )GetProcAddress( g_hZlib, FN_inflateEnd );
        if ( NULL == zlib_inflateEnd )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_inflateInit_ = ( PFN_inflateInit_ )GetProcAddress( g_hZlib, FN_inflateInit_ );
        if ( NULL == zlib_inflateInit_ )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }

        zlib_inflateInit2_ = ( PFN_inflateInit2_ )GetProcAddress( g_hZlib, FN_inflateInit2_ );
        if ( NULL == zlib_inflateInit2_ )
        {
            hr = HRESULT_FROM_WIN32( GetLastError() );
            goto Exit0;
        }
    }
Exit0:
    if ( FAILED( hr ) )
    {
        zlib_compress = NULL;
        zlib_uncompress = NULL;

        FreeLibrary( g_hZlib );
        g_hZlib = NULL;
    }

    m_lock.Unlock();
    return hr;
#endif
}