用途
对二次开发过程中用到的功能进行梳理过程中,将单个完整的功能单独拿出来整理成一个独立完整的 dll,便于后期整合应用,也方便分享。在这一过程中每完成一个功能就要写一个 dat 文件,比较麻烦。于是就用 C++写了一个可以批量生成 dat 文件的小程序。可以根据当前目录下存在的 dll 来生成对应 dat 文件数据行
代码
递归遍历当前目录下所有文件及其子目录下文件,遇到*.dll 则生成相应的数据行。
void GenDatFile(const wchar_t *path, ofstream *file)
{
//文件句柄
intptr_t hFile = 0;
//文件信息
struct _wfinddata64i32_t fileinfo; //包含中文目录,使用宽字符
wstring p;
if ((hFile = _wfindfirst(p.assign(path).append(L"\\*").c_str(), &fileinfo)) != -1)
{
do
{
if (fileinfo.attrib & _A_SUBDIR)
{
if (wcscmp(fileinfo.name, L".") != 0 && wcscmp(fileinfo.name, L"..") != 0)
{
GenDatFile(p.assign(path).append(L"\\").append(fileinfo.name).c_str(), file);
}
}
else