windows 打开系统设置(SystemSettings.exe)c++

cpp 复制代码
#include <iostream>
#include <stdlib.h> 
#include <tchar.h>
#include <string> 
#include <windows.h> 
#include <KnownFolders.h>
#include <shlobj.h>

void shellrun1() {
	wchar_t system_buffer[MAX_PATH];
	system_buffer[0] = 0;
	::GetSystemDirectory(system_buffer, MAX_PATH);

	std::wstring sys_path(system_buffer);
	std::wstring rundll32 = sys_path + _T("\\rundll32.exe");

	std::wstring shell32dll = sys_path + _T("\\shell32.dll");

	std::wstring inetcpl = sys_path + _T("\\inetcpl.cpl,,4");

	std::wstring args(shell32dll);
	args.append(L",Control_RunDLL ");
	args.append(inetcpl);

	::ShellExecute(NULL, L"open", rundll32.c_str(), args.c_str(), NULL,
		SW_SHOWNORMAL);
}

void shellrun2(std::string url) {

	char system_buffer[MAX_PATH];
	system_buffer[0] = 0;
	::GetSystemDirectoryA(system_buffer, MAX_PATH);
	std::string sys_path(system_buffer);

	std::string escaped_url(url);
	escaped_url.insert(0, "\"");
	escaped_url += "\"";

	if (reinterpret_cast<ULONG_PTR>(ShellExecuteA(
		NULL, "open", escaped_url.c_str(), NULL,
		sys_path.c_str(), SW_SHOWNORMAL)) <= 32) {
		return;
	}

}
int main()
{
	//网络代理 只需将特定url粘贴打开即可,其他的更多参考下方微软链接
	std::string url("ms-settings:network-proxy");
	shellrun2(url);

	//相机设置
	std::string came_url("ms-settings:privacy-webcam");
	shellrun2(came_url);

	//搜索设置
	std::string search_url("ms-settings:search");
	shellrun2(search_url);

}

//打开其他设置项参考:

// https://learn.microsoft.com/en-us/windows/uwp/launch-resume/launch-settings-app#network--internet

截取部分,需要打开的项复制进去即可

效果图:

相关推荐
郝学胜-神的一滴8 分钟前
Linux系统函数stat和lstat详解
linux·运维·服务器·开发语言·c++·程序人生·软件工程
编程岁月13 分钟前
java面试-0141-java反射?优缺点?场景?原理?Class.forName和ClassLoader区别?
java·开发语言·面试
、花无将21 分钟前
PHP:配置问题从而导致代码运行出现错误
开发语言·php
小小测试开发27 分钟前
pytest 库用法示例:Python 测试框架的高效实践
开发语言·python·pytest
BUG弄潮儿37 分钟前
go-swagger标准接口暴露
开发语言·后端·golang
数字化顾问1 小时前
Flink ProcessFunction 与低层级 Join 实战手册:实时画像秒级更新系统
java·开发语言
qq_339191141 小时前
go win安装grpc-gen-go插件
开发语言·后端·golang
疯狂吧小飞牛1 小时前
Lua中,表、元表、对象、类的解析
开发语言·junit·lua
鹿鸣天涯1 小时前
Wine 10.15 发布!Linux 跑 Windows 应用更丝滑了
linux·运维·windows
owCode1 小时前
3-C++中类大小影响因素
开发语言·c++