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

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

效果图:

相关推荐
nice_lcj52032 分钟前
深入理解 Java 反射:从 Class 对象到方法调用(含性能实测 + 迷你 IOC 实战 + 面试考点)
java·开发语言·后端·面试
樱花树下的数学喵2 小时前
手写简易 STL string|C++ 字符串底层实现
开发语言·c++
AI吃大瓜3 小时前
指针压力表读数3:C/C++实现指针压力表读数(可实时检测)
c++·指针读数·指针压力表·压力表自动读数·压力表读数
-银雾鸢尾-3 小时前
两数之和-C++实现
c++·算法
j7~3 小时前
【动态规划算法专题】动态规划五部曲实战:泰波那契数、三步问题、最小花费爬楼梯
c++·算法·动态规划·数据结构与算法
jimy13 小时前
C++ 报错的 qualifiers 的意思
开发语言·c++
揽星河..3 小时前
【C++】类和对象
c++·算法
D e re k ZH4 小时前
C++ 并发、未定义行为与工程化难点(No 3)
数据结构·c++·算法·面试
不积跬步无以至千里mmbb264 小时前
rust_analysis
开发语言·后端·rust
暴力求解5 小时前
C++ ---继承(二)
开发语言·c++·算法