您的位置:首页 > 编程语言 > C语言/C++

以管理员身份运行指定程序 visual c++

2013-10-22 10:16 633 查看
_declspec(dllexport)

int WINAPI icePub_runByAdmin(char *strAppPathName,char *strSuParam);

//以管理员身份运行指定程序 visual c++

int runByAdmin(void)

{

int retCode=-1;

typedef int (WINAPI ICEPUB_RUNBYADMIN)(char *strAppPathName,char *strSuParam);

ICEPUB_RUNBYADMIN *icePub_runByAdmin = 0;

HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll");

if(hDLLDrv)

icePub_runByAdmin = (ICEPUB_RUNBYADMIN *)GetProcAddress(hDLLDrv, "icePub_runByAdmin");

if(icePub_runByAdmin)

retCode=icePub_runByAdmin("E:\\c++\\IsAdmin\\setup.bat","");

if(hDLLDrv)

FreeLibrary(hDLLDrv);

if(retCode == 0)

exit(0);

if(retCode == -1)

AfxMessageBox("以管理员启动失败,请手动启动");

return retCode;

}

icePubDll.dll 下载地址:

http://www.pudn.com/downloads369/sourcecode/windows/detail1598958.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: