HKEY hKey = nullptr;
if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\services\\NetBT\\Parameters"), 0, KEY_WRITE, &hKey))
{
AfxMessageBox(L"打开注册表失败");
return;
}
if (nDigits == 64)
{
// if (ERROR_SUCCESS != RegCreateKey(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\CurrentControlSet\\services\\NetBT\\Parameters\\SMBDeviceEnabled"), &hKey))
// {
// AfxMessageBox(L"创建注册表失败");
// return;
// }
if (ERROR_SUCCESS != RegSetValueEx(hKey, L"SMBDeviceEnabled", 0, REG_QWORD, (BYTE*)&nQword, sizeof(QWORD)))
{
AfxMessageBox(L"写入注册表失败");
return;
}
}
else if (nDigits == 32)
{
if (ERROR_SUCCESS != RegSetValueEx(hKey, L"SMBDeviceEnabled", 0, REG_QWORD, (BYTE*)&nDword, sizeof(DWORD)))
{
AfxMessageBox(L"写入注册表失败");
return;
}
}
RegCloseKey(hKey);
if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\services\\NetBT\\Parameters"), 0, KEY_WRITE, &hKey))
{
AfxMessageBox(L"打开注册表失败");
return;
}
if (nDigits == 64)
{
// if (ERROR_SUCCESS != RegCreateKey(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\CurrentControlSet\\services\\NetBT\\Parameters\\SMBDeviceEnabled"), &hKey))
// {
// AfxMessageBox(L"创建注册表失败");
// return;
// }
if (ERROR_SUCCESS != RegSetValueEx(hKey, L"SMBDeviceEnabled", 0, REG_QWORD, (BYTE*)&nQword, sizeof(QWORD)))
{
AfxMessageBox(L"写入注册表失败");
return;
}
}
else if (nDigits == 32)
{
if (ERROR_SUCCESS != RegSetValueEx(hKey, L"SMBDeviceEnabled", 0, REG_QWORD, (BYTE*)&nDword, sizeof(DWORD)))
{
AfxMessageBox(L"写入注册表失败");
return;
}
}
RegCloseKey(hKey);