出于某種原因,我需要將檔案放入 DLL 中。我知道我可以把它放在一個純資源的 DLL 中,但我不想讓其他人知道如何讀取這個檔案。 所以我希望能夠把這個檔案和如何讀取這個檔案的函式一起放在一個 DLL 中檔案。有誰知道這是怎么做到的嗎 ?謝謝
uj5u.com熱心網友回復:
這是一個想法。將檔案存盤為 base64 編碼
$ cat file.txt
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
$ cat file.txt | base64 > base64.txt
$ cat base64.txt
SGVsbG8gV29ybGQKSGVsbG8gV29ybGQKSGVsbG8gV29ybGQKSGVsbG8gV29ybGQKSGVsbG8gV29y
bGQKSGVsbG8gV29ybGQKCg==
然后在你的 C 檔案中
static std::string fileout = R"(
SGVsbG8gV29ybGQKSGVsbG8gV29ybGQKSGVsbG8gV29ybGQKSGVsbG8gV29ybGQKSGVsbG8gV29y
bGQKSGVsbG8gV29ybGQKCg==
)";
std::string readme() {
return base64::decode( fileout );
}
你可以在這里找到幾個 base64::decode() 版本: Base64 decode snippet in C
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/395869.html