通过修改注册表来设置系统的端口,服务,共享等,
本实例将用到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
);