Skip to content

Instantly share code, notes, and snippets.

@HaiyongJiang
Created May 8, 2015 09:13
Show Gist options
  • Save HaiyongJiang/6d03f33854118853c4f9 to your computer and use it in GitHub Desktop.
Save HaiyongJiang/6d03f33854118853c4f9 to your computer and use it in GitHub Desktop.
load dependency dll ,add env path.
bool LoadDependencyDLL(const std::string path)
{
std::vector<std::string> filters;
filters.push_back("*.dll");
filters.push_back("*.DLL");
std::vector<std::string> fileList = getFileNameLists(path, filters, false, true);
for(int i=0; i<fileList.size(); i++)
{
if(fileList[i].find(".dll") != -1)
{
std::cout << "Load dynamic library: " << fileList[i] << "\n";
::SetDllDirectory(path.c_str());
::LoadLibraryA(fileList[i].c_str());
}
}
return true;
}
bool AddENVPath(const std::string path)
{
std::cout << "Add env: " << path << "\n";
::_putenv(path.c_str());
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment