绝对路径加载dll

来源:互联网 发布:ps淘宝9秒视频制作 编辑:程序博客网 时间:2024/06/08 00:23
char curpath[128] = {0};

GetModuleFileNameA(NULL,curpath,sizeof(curpath)); //获取应用程序的路径

       // 去除最后的应用程序名xxx.exe

string str(curpath);
string::size_type pos = str.find_last_of("\\");
if(pos != string::npos)
{
str = str.substr(0,pos)+"\\StandardSDK\\pis";

}

//设置dll的绝对路径

bool flag = SetDllDirectoryA(str.c_str()); //设置dll的绝对路径

        //加载dll

m_hLib = ::LoadLibraryA("XXX.dll");

        if(m_hLib != NULL)

{

}

0 0
原创粉丝点击