Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
function StringToBase64(instr: string; Flags: dword): string;
var
sz: dword;
begin
CryptBinaryToStringA(pointer(instr), Length(instr), Flags, nil, sz);
SetLength(result, sz);
CryptBinaryToStringA(pointer(instr), Length(instr), Flags, pointer(result), sz);
end;
cstr := StringToBase64(instr, CRYPT_STRING_BASE64);
function StringFromBase64(instr: string; Flags: dword): string;
var
sz, skip: dword;
begin
CryptStringToBinaryA(pointer(instr), Length(instr), Flags, nil, sz, skip,
Flags);
SetLength(result, sz);
CryptStringToBinaryA(pointer(instr), Length(instr), Flags, pointer(result),
sz, skip, Flags);
end;
cstr := StringFromBase64(cstr, CRYPT_STRING_BASE64);
procedure Base64EncFile(infilename, outfilename: string);
// copies file in infile to outfile. Uses file mapping to read, but regular
// Delphi "file" to write.
var
FileHandle: THandle;
MapHandle: THandle;
ViewPointer: Pointer;
outptr: Pointer;
outfile: file;
outsize: longint;
begin
FileHandle := CreateFile(Pchar(infilename), GENERIC_READ,
FILE_SHARE_READ or FILE_SHARE_WRITE,nil, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL or FILE_FLAG_SEQUENTIAL_SCAN, 0);
MapHandle := CreateFileMapping(FileHandle, nil, PAGE_READONLY, 0, 0, nil);
ViewPointer := MapViewOfFile(MapHandle, FILE_MAP_READ, 0, 0, 0);
if ViewPointer <> nil then
try
Assign(outfile, outfilename);
rewrite(outfile, 1);
CryptBinaryToStringA(ViewPointer, GetFileSize(FileHandle, nil),
CRYPT_STRING_BASE64, nil, outsize);
GetMem(outptr, outsize);
CryptBinaryToStringA(ViewPointer, GetFileSize(FileHandle, nil),
CRYPT_STRING_BASE64, outptr, outsize);
BlockWrite(outfile, outptr^, outsize);
Close(outfile);
FreeMem(outptr);
finally
UnMapViewofFile(ViewPointer);
end;
CloseHandle(maphandle);
CloseHandle(FileHandle);
end;