Creates a new CMS compressed-data file (.p7z) from an existing input file.
Public Declare Function CMS_MakeComprData Lib "diCrPKI.dll" (ByVal strFileOut As String, ByVal strFileIn As String, ByVal nOptions As Long) As Long
nRet = CMS_MakeComprData(strFileOut, strFileIn, nOptions) As Long
long __stdcall CMS_MakeComprData(const char *szFileOut, const char *szFileIn, long nOptions);
If successful, the return value is zero; otherwise it returns a negative error code.
static int dipki::Cms::MakeComprData (const std::string &outputFile, const std::string &inputFile)
static Cms.make_comprdata(outputfile, inputfile)
This creates a CMS compressed-data file (conventionally saved with a .p7z extension) using the zlibCompress
algorithm.
It only works in file-to-file mode.
Any existing file with the same name as the parameter szFileOut will be overwritten without warning.
Note that it may not produce an exact identical output to that of another program on the same input
due to differences in ZLIB buffers and window sizes.
Dim nRet As Long Dim strBaseFile As String Dim strCompFile As String Dim strChkFile As String Dim strFileType As String strBaseFile = "sonnets.txt" strCompFile = "sonnets.p7z" ' Create a CMS compressed-data file nRet = CMS_MakeComprData(strCompFile, strBaseFile, 0) Debug.Print "CMS_MakeComprData returns " & nRet & " (expecting 0)" Debug.Print "FileLen('" & strBaseFile & "')=" & FileLen(strBaseFile) Debug.Print "FileLen('" & strCompFile & "')=" & FileLen(strCompFile) ' Check ASN.1 file type strFileType = String(PKI_ASN1_TYPE_MAXCHARS, " ") nRet = ASN1_Type(strFileType, Len(strFileType), strCompFile, 0) Debug.Print "File Type='" & Left(strFileType, nRet) & "'" ' Now check we can read it strChkFile = "sonnets-uncompr.txt" nRet = CMS_ReadComprData(strChkFile, strCompFile, 0) Debug.Print "CMS_ReadComprData returns " & nRet & " (expecting +ve)" ' And check with no-inflate option strChkFile = "sonnets-noinflate.txt" nRet = CMS_ReadComprData(strChkFile, strCompFile, PKI_CMS_NO_INFLATE) Debug.Print "CMS_ReadComprData(PKI_CMS_NO_INFLATE) returns " & nRet & " (expecting +ve)"
CMS_MakeComprData returns 0 (expecting 0) FileLen('sonnets.txt')=106081 FileLen('sonnets.p7z')=40862 File Type='PKCS7/CMS COMPRESSED DATA ' CMS_ReadComprData returns 106081 (expecting +ve) CMS_ReadComprData(PKI_CMS_NO_INFLATE) returns 40770 (expecting +ve)