Code: Select all
#DllLoad Crypt32.dll
bufferToBase64(buf) {
if !DllCall('Crypt32.dll\CryptBinaryToString', 'Ptr', buf, 'UInt', buf.Size, 'UInt', 1, 'Ptr', 0, 'UInt*', numChars := 0)
throw 'cant compute the destination buffer size, error: ' A_LastError
bufString := BufferAlloc(numChars * 2)
if !DllCall('Crypt32.dll\CryptBinaryToString', 'Ptr', buf, 'UInt', buf.Size, 'UInt', 1, 'Ptr', bufString, 'UInt*', bufString.Size)
throw 'cant convert source buffer to base64, error: ' A_LastError
return StrGet(bufString)
}
base64ToBuffer(ByRef strBase64) {
if !DllCall('Crypt32.dll\CryptStringToBinary', 'Str', strBase64, 'UInt', 0, 'UInt', 1, 'Ptr', 0, 'UInt*', numBytes := 0, 'UInt*', 0, 'UInt*', 0)
throw 'cant compute the destination buffer size, error: ' A_LastError
buf := BufferAlloc(numBytes)
if !DllCall('Crypt32.dll\CryptStringToBinary', 'Str', strBase64, 'UInt', 0, 'UInt', 1, 'Ptr', buf, 'UInt*', buf.Size, 'UInt*', 0, 'UInt*', 0)
throw 'cant convert base64 to buffer, error: ' A_LastError
return buf
}
base64ToClipboardAll(ByRef strBase64) {
buf := base64ToBuffer(strBase64)
return ClipboardAll(buf, buf.Size)
}
A_Clipboard := 'helloworld'
ClipData := ClipboardAll()
CompanyLogoBase64 := bufferToBase64(ClipData)
A_Clipboard := ''
A_Clipboard := base64ToClipboardAll(CompanyLogoBase64)
MsgBox A_Clipboard
If it were possible to write multiple ClipDatas to a single binary file, that would work great, too.
it is possible. invent ur own serialization/deserialization scheme and write out/parse the bytes according to it. use loops and
FileObject's methods