通过修改注册表来设置系统的端口,服务,共享等,
本实例将用到RegCreateKey和RegSetValueEx两个函数对注册表进行修改;
以关闭445端口为例:
if(m_445duankou==TRUE)
{
c=0;
CString skey="System//CurrentControlSet//Services//NetBT//Parameters";
::RegCreateKey(HKEY_LOCAL_MACHINE,skey,&sub); ///打开注册表项
RegSetValueEx(sub,"SMBDeviceEnabled",NULL,REG_DWORD,(BYTE*)&c,sizeof(DWORD));//对键值进行修改
::RegCloseKey(sub); //关闭注册表;
}
本软件的主要特点是通过修改键值来实现的;
LONG RegCreateKey(
HKEY hKey, // handle to an open key
LPCTSTR lpSubKey, // address of name of subkey to open
PHKEY phkResult // address of buffer for opened handle
);
LONG RegSetValueEx(
HKEY hKey, // handle to key to set value for
LPCTSTR lpValueName, // name of the value to set
DWORD Reserved, // reserved
DWORD dwType, // flag for value type
CONST BYTE *lpData, // address of value data
DWORD cbData // size of value data
);
本文介绍如何使用RegCreateKey和RegSetValueEx函数修改注册表,以实现关闭系统445端口的目的。通过修改注册表键值'SMBDeviceEnabled'为0,可以禁用该端口。
3万+

被折叠的 条评论
为什么被折叠?



