如何将文件和导出的函数放在一个 dll 中?

how to put files and exported functions in one dll?

出于某种原因,我需要将文件放入 DLL 中。我知道我可以把它放在一个纯资源 DLL 中,但我不想让其他人知道如何读取该文件。 所以我希望能够将此文件连同有关如何读取文件的函数一起放入 DLL 中。 有谁知道这是怎么做到的吗 ?谢谢

这是一种对文本文件和二进制文件都适用的想法。

将文件存储为使用

编码的 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++