c++遍历文件

void search_plugins()
{
    if (!fs::exists(pluginDir) || !fs::is_directory(pluginDir)) 
    {
        std::cerr << "目录不存在或不是有效目录: " << pluginDir << std::endl;
        return;
    }
    for (const auto& entry : fs::directory_iterator(pluginDir)) {
        if (entry.is_regular_file() && 
            entry.path().extension() == ".dll") {
            
            std::string dllPath = entry.path().string();
            std::cout << "找到DLL文件: " << dllPath << std::endl;
            
            // 在这里可以加载DLL文件
            // LoadLibrary(dllPath.c_str()); // Windows API
        }
    }
}

 

posted on 2025-12-23 15:20  小沙盒工作室  阅读(2)  评论(0)    收藏  举报