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

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

效果图:

相关推荐
侃侃_天下18 分钟前
最终的信号类
开发语言·c++·算法
博笙困了39 分钟前
AcWing学习——差分
c++·算法
echoarts44 分钟前
Rayon Rust中的数据并行库入门教程
开发语言·其他·算法·rust
Aomnitrix1 小时前
知识管理新范式——cpolar+Wiki.js打造企业级分布式知识库
开发语言·javascript·分布式
青草地溪水旁1 小时前
设计模式(C++)详解—抽象工厂模式 (Abstract Factory)(2)
c++·设计模式·抽象工厂模式
青草地溪水旁1 小时前
设计模式(C++)详解—抽象工厂模式 (Abstract Factory)(1)
c++·设计模式·抽象工厂模式
感哥1 小时前
C++ std::vector
c++
zl_dfq1 小时前
C++ 之【C++11的简介】(可变参数模板、lambda表达式、function\bind包装器)
c++
每天回答3个问题2 小时前
UE5C++编译遇到MSB3073
开发语言·c++·ue5
凯子坚持 c2 小时前
精通 Redis list:使用 redis-plus-plus 的现代 C++ 实践深度解析
c++·redis·list