LZNV Tester CPP File Contents


   Function _loadDLL


_loadDLL is a sample function that shows how to work with the LZNV SDK DLL


/// \brief      LZNV_Encode_File performs a straight forward file compression without the need of any prior buffer manipulation.

/// \note       The function will perform internal buffering. If you want to perform your own buffering, please use LZNV_Encode_Buffer.

/// \param[in]  _encoding_method            One of the methods _LZNV_ULTRAFAST_COMPRESSION to _LZNV_BETTER_COMPRESSION or _LZNV_HUFFMAN_COMPRESSION to _LZNV_RLE64_COMPRESSION.

/// \param[in]  _memory_level            The working size of the LZ algorithm. _LZNV_BUFFER_SIZE_256KB_INDX to _LZNV_BUFFER_SIZE_16MB_INDX.

/// \param[in]  _wchr_filename_to_compress            Input file path to compress. Unicode WCHAR.

/// \param[in]  _wchr_output_filename            Output file path to compress. Unicode WCHAR.

/// \return     returns NO_ERROR (0) in case of no errors or one of the error codes defined in LZNV_Defines.h header file

///             possible values:

///             - _LZNV_ERROR_INVALID_COMPRESSION_METHOD      

///             - _LZNV_ERROR_INVALID_BUFFER_SIZE            

///             - _LZNV_ERROR_EXPORTED_MAIN_FUNC_NOT_FOUND    

///             - _LZNV_ERROR_INVALID_PROCESS_SIZE            

///              


int32_t _loadDLL()

{

    LZNV_DLL_handle = LoadLibrary(LZNV_DLL_Name);


    if (LZNV_DLL_handle == NULL)

    {

        wprintf(L"\n\n ERROR While Loading Encode DLL %s. Error: %s\n", LZNV_DLL_Name, _getLastErrorString());

        return _LZNV_ERROR_DLL_NOT_FOUND;

    }


    IMPORT_DLL_PROCEDURE_(PF_LZNV_DLL_MAIN_FILE, _p_LZNV_DLL_Main_File_funct, LZNV_DLL_MAIN_FILE_, L"Successfully found LZNV Main Export function");

    IMPORT_DLL_PROCEDURE_(PF_LZNV_DLL_MAIN_BUFFER, _p_LZNV_DLL_Main_Buffer_funct, LZNV_DLL_MAIN_BUFFER_, L"Successfully found LZNV Main Export function");


    ASSERT(_p_LZNV_DLL_Main_File_funct);

    if (!_p_LZNV_DLL_Main_File_funct) {

        return _LZNV_ERROR_EXPORTED_MAIN_FUNC_NOT_FOUND;

    }


    ASSERT(_p_LZNV_DLL_Main_Buffer_funct);

    if (!_p_LZNV_DLL_Main_Buffer_funct) {

        return _LZNV_ERROR_EXPORTED_MAIN_FUNC_NOT_FOUND;

    }


    return 0;

}