メモリ内圧縮用にXceedzip.dll COMコンポーネント4.2を使用しています(これはthisドキュメントを参照しています)。xceedCompressionClass compressはxceSuccessを返しますが、圧縮しません。
public void compressionCode(const char *loginRequestData) {
XceedCompression ^compression = gcnew XceedCompressionClass();
compression->License("My License Key!");
xcdCompressionError r_error;
VARIANT r_dataToCompress;
VARIANT r_compressedData;
VARIANT r_uncompressedData;
SAFEARRAY *r_safeArray;
char *r_safeArrayData;
size_t r_length;
r_length = strlen(loginRequestData);
r_safeArray = SafeArrayCreateVector(VT_I1, 0, r_length);
SafeArrayAccessData(r_safeArray, (void**)&r_safeArrayData);
CopyMemory(r_safeArrayData, loginRequestData, r_length);
SafeArrayUnaccessData(r_safeArray);
VariantInit(&r_dataToCompress);
VariantInit(&r_compressedData);
VariantInit(&r_uncompressedData);
r_dataToCompress.vt = VT_ARRAY | VT_I1;
r_dataToCompress.parray = r_safeArray;
//r_compressedData.vt = VT_ARRAY | VT_I1;
//r_compressedData.parray = r_safeArray;
IntPtr r_intPtrDataToCompress = (IntPtr)&r_dataToCompress;
Object ^r_dataToCompressObject = Marshal::GetObjectForNativeVariant(r_intPtrDataToCompress);
IntPtr r_intPtrCompressedData = (IntPtr)&r_compressedData;
Object ^r_CompressedDataObject = Marshal::GetObjectForNativeVariant(r_intPtrCompressedData);
r_error = compression->Compress(r_dataToCompressObject, r_CompressedDataObject, VARIANT_TRUE);
//VariantClear(&r_dataToCompress);
if (r_error != xcdCompressionError::xceSuccess)
Console::WriteLine("Error Encountered!");
if (r_CompressedDataObject != NULL) {
PrintByteArrayVariant< unsigned char >(&r_compressedData);
} else {
Console::WriteLine("compressed Data Object NULL !");
}}
template< class DataType > static void PrintByteArrayVariant(VARIANT * variant) {
DataType * data;
SAFEARRAY * arrayDescriptor;
int i, count;
// Get the array descriptor from the variant
arrayDescriptor = variant->parray;
// Gain access to the array data
SafeArrayAccessData(arrayDescriptor, (void **)&data);
// Get the number of elements in the first dimension of the array
count = arrayDescriptor->rgsabound[0].cElements/sizeof(DataType);
int lineThreshold = 32/sizeof(DataType);
int groupThreshold = 4/sizeof(DataType);
char buffer[16];
sprintf(buffer, "%%0%dX", sizeof(DataType) * 2);
for (i = 0; i < count; i++)
{
// If we need to change line
if ((i % lineThreshold) == 0 && i > 0)
printf("\n");
// If we need to seperate a group of data
if ((i % groupThreshold) == 0)
printf(" ");
// Access the current index as we would a normal array
printf(buffer, data[i]);
}
// Release access to the array data
SafeArrayUnaccessData(arrayDescriptor);
}
public void compressionCode(const char *loginRequestData) {
XceedCompression ^compression = gcnew XceedCompressionClass();
compression->License("My License Key!");
xcdCompressionError r_error;
VARIANT r_dataToCompress;
VARIANT r_compressedData;
VARIANT r_uncompressedData;
SAFEARRAY *r_safeArray;
char *r_safeArrayData;
size_t r_length;
r_length = strlen(loginRequestData);
r_safeArray = SafeArrayCreateVector(VT_I1, 0, r_length);
SafeArrayAccessData(r_safeArray, (void**)&r_safeArrayData);
CopyMemory(r_safeArrayData, loginRequestData, r_length);
SafeArrayUnaccessData(r_safeArray);
VariantInit(&r_dataToCompress);
VariantInit(&r_compressedData);
VariantInit(&r_uncompressedData);
r_dataToCompress.vt = VT_ARRAY | VT_I1;
r_dataToCompress.parray = r_safeArray;
//r_compressedData.vt = VT_ARRAY | VT_I1;
//r_compressedData.parray = r_safeArray;
IntPtr r_intPtrDataToCompress = (IntPtr)&r_dataToCompress;
Object ^r_dataToCompressObject = Marshal::GetObjectForNativeVariant(r_intPtrDataToCompress);
IntPtr r_intPtrCompressedData = (IntPtr)&r_compressedData;
Object ^r_CompressedDataObject = Marshal::GetObjectForNativeVariant(r_intPtrCompressedData);
r_error = compression->Compress(r_dataToCompressObject, r_CompressedDataObject, VARIANT_TRUE);
//VariantClear(&r_dataToCompress);
if (r_error != xcdCompressionError::xceSuccess)
Console::WriteLine("Error Encountered!");
if (r_CompressedDataObject != NULL) {
PrintByteArrayVariant< unsigned char >(&r_compressedData);
} else {
Console::WriteLine("compressed Data Object NULL !");
}}
template< class DataType > static void PrintByteArrayVariant(VARIANT * variant) {
DataType * data;
SAFEARRAY * arrayDescriptor;
int i, count;
// Get the array descriptor from the variant
arrayDescriptor = variant->parray;
// Gain access to the array data
SafeArrayAccessData(arrayDescriptor, (void **)&data);
// Get the number of elements in the first dimension of the array
count = arrayDescriptor->rgsabound[0].cElements/sizeof(DataType);
int lineThreshold = 32/sizeof(DataType);
int groupThreshold = 4/sizeof(DataType);
char buffer[16];
sprintf(buffer, "%%0%dX", sizeof(DataType) * 2);
for (i = 0; i < count; i++)
{
// If we need to change line
if ((i % lineThreshold) == 0 && i > 0)
printf("\n");
// If we need to seperate a group of data
if ((i % groupThreshold) == 0)
printf(" ");
// Access the current index as we would a normal array
printf(buffer, data[i]);
}
// Release access to the array data
SafeArrayUnaccessData(arrayDescriptor);
}
圧縮メソッドの戻り値はxceSuccessが、r_compressedDataは空です。 何が間違っているか考えてみましょうか?私はライブラリーのキーが期限切れになっているかもしれないが、戻り値としてxceSuccessを取得しているので、それが当てはまるとは思わない。
バージョン4.2 DOEのではメールサポートのための私達に連絡することができますxcdCompressionError列挙型の「ライセンスキーが古すぎます」というエラーメッセージは表示されません。しかし、私はこれが当てはまるべきではないことに同意します。 –