使exe以管理员权限运行

win10权限

	SHELLEXECUTEINFO ShExecInfo = {0};  
	ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);  
	ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;  
	ShExecInfo.hwnd = NULL;  
	ShExecInfo.lpVerb = LPCSTR("runas");  
	ShExecInfo.lpFile = LPCSTR("cmd");
	ShExecInfo.lpParameters = LPCSTR("");
	ShExecInfo.lpDirectory = NULL;  
	ShExecInfo.nShow = SW_SHOW;
	ShExecInfo.hInstApp = NULL;  
	ShellExecuteEx(&ShExecInfo);  

运行效果

直接运行cmd效果下图:
在这里插入图片描述
上述代码运行之后效果:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_34940879/article/details/103977380