WebDev设置工具

编译好的工具下载https://1drv.ms/u/s!AvlbNd7del19pEU0G0kWlDLywkk-?e=0bKJaa
本工具就是为了免去找注册表的麻烦,而且主要我是不会什么bat,powershell也不想看,不想学,莫问!

#include 
#include 
#include 
int main()
{
	using namespace std;
	cout << "是否开启Http WebDav:";
	DWORD ddata=4;
	int s4i,s4o;
	int err;
	if ((err = RegGetValueW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\WebClient\\Parameters", L"BasicAuthLevel", RRF_RT_DWORD, 0, &s4o, &ddata)) == ERROR_SUCCESS)
		cout << (s4o == 2 ? "是" : "否") << endl;
	else
		cout << "错误:" << err << endl;
	cout << "可写入文件大小:";
	//FileSizeLimitInBytes
	if ((err = RegGetValueW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\WebClient\\Parameters", L"FileSizeLimitInBytes", RRF_RT_DWORD, 0, &s4i, &ddata)) == ERROR_SUCCESS)
		cout << s4i << "byte  " << (s4i / 1024) << "KB  " << (s4i / pow(1024 , 2)) << "MB  " << (s4i / pow(1024 , 3)) << "GB" << endl;
	else
		cout << "错误:" << err << endl;
	///////
	HKEY keyi;
	if (RegOpenKeyW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\WebClient\\Parameters", &keyi) != ERROR_SUCCESS)
		cout << "请使用管理员权限开启!" << endl;
	///////
	do {
		if (s4o == 2)
			cout << "<1> 关闭HTTP WebDav" << endl;
		else
			cout << "<1> 开启HTTP WebDav" << endl;
		cout << "<2> 设置可写文件大小,现在" << (s4i / pow(1024, 2)) << "MB"<< endl;

		cout << "请选择:";
		int i; DWORD dwi;
		cin >> i;
		switch (i)
		{
		case 1:
			if (s4o == 2)
			{
				dwi = 1;
				s4o = 1;
			}
			else
			{
				dwi = 2;
				s4o = 2;
			}
			RegSetValueEx(keyi, L"BasicAuthLevel", NULL, REG_DWORD, (const BYTE *)&dwi, ddata);
			break;
		case 2:
			cout << "<1> 设置成 50MB" << endl;
			cout << "<2> 设置成  4GB" << endl;
			cout << "----最高4GB----" << endl;
			cin >> i;
			switch (i)
			{
			case 1:
				dwi = 0x2faf080; s4i = dwi;
				RegSetValueEx(keyi, L"FileSizeLimitInBytes", NULL, REG_DWORD, (const BYTE*)& dwi, ddata);
				break;
			case 2:
				dwi = 0xffffffff; s4i = dwi;
				RegSetValueEx(keyi, L"FileSizeLimitInBytes", NULL, REG_DWORD, (const BYTE*)& dwi, ddata);
				break;
			default:
				cout << "我是让你选,你瞧瞧你瞎输的什么?啊?" << endl;
				break;
			}
			break;
		default:
			cout << "我是让你选,你瞧瞧你瞎输的什么?啊?" << endl;
			break;
		}
	} while (1);
	return 0;
}

参考文章https://www.wangzhengzhen.com/?p=1003

你可能感兴趣的:(C,NextCloud)