![]() |
#1 |
Участник
|
Вызов функции DLL
Всем привет!
Нужно переконвертировать строку обычную в строку base64 Аксапта 3.0 Хочу использовать CryptBinaryToString из DLL crypt32.dll https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx Набросал джоб для тестов X++: static void Str2Base64(Args _args) { #define.minTIFSz(30000) // Minimum try #define.maxTIFSz(900000) // Maximum try #define.TIFSzInc(10000) // Increments during trying #define.sizeOfInt(4) #define.moredata(234) DLL DLL = new DLL('crypt32.dll'); DLLFunction encode = new DLLFunction(DLL, 'CryptBinaryToStringA'); int retval; // BOOL int encodedlen; int lasterr; Binary binary; Binary junk1 = new Binary(#SizeOfInt); Binary junk2 = new Binary(#SizeOfInt); Binary size = new Binary(#SizeOfInt); Binary x = new Binary(64); int TIFsz; BinData binData = new BinData(); //TextBuffer tb = new TextBuffer(); Container dataCon; str ret; int counter; #define.TestStr('Test') Binary BinData2Binary(BinData _bd) { Binary b; int i; int num; ; num = _bd.getVariant().safeArray().lastIndex(); b = new Binary(num+1); for(i=1; i<(num+1); i++) { b.byte(i-1, _bd.getVariant().safeArray().value(i)); } return b; } //#define.InStr('U29tZSB0ZXh0') /* [url]http://msdn.microsoft.com/en-us/library/aa380285(VS.85).aspx[/url] BOOL WINAPI CryptBinaryToString( In const BYTE *pbBinary, In DWORD cbBinary, In DWORD dwFlags, Out_opt LPTSTR pszString, Inout DWORD *pcchString ); */ encode.returns(ExtTypes::DWord); // BOOL encode.arg( Exttypes::Byte, Exttypes::DWord, Exttypes::DWord, Exttypes::String, Exttypes::DWord ); binData.setStrData(#TestStr); binary = binData2Binary(binData); TIFSz = #minTIFSz; lasterr = #moredata; while (lasterr == #moredata) { if (TIFSz > #maxTIFSz) throw error(strfmt("The eInvoice image is larger than %1 bytes - cannot handle this",#maxTIFSz)); //TODO:Label Size.dWord(0, binData.getVariant().safeArray().lastIndex() + 1); retval = encode.call( binary, binData.getVariant().safeArray().lastIndex()+1, 1, // Base64, without headers ret, counter); lasterr = DLL::lastDLLError(); TifSz += #TIFSzInc; } if (!retval) { error(strfmt("%1 (%2)",WINAPI::formatMessage(lasterr),lasterr)); } info(ret); } Делаю по аналогии с http://lehr.dk/dynax.php там обратная функция |
|