码迷,mamicode.com
首页 > 编程语言 > 详细

C++关闭默认共享

时间:2018-07-03 14:40:16      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:show   mds   cmd   lsa   har   rev   cal   controls   turn   

 1 #include <windows.h>
 2 using namespace std;
 3 
 4 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
 5                     LPSTR lpCmdLine, int nCmdShow)
 6 {
 7     HKEY hKEY;    
 8     char *SharePath = "SYSTEM\\CurrentControlSet\\services\\LanmanServer\\Parameters";
 9     DWORD dwShare = 0;
10     
11     if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, SharePath, 0, KEY_SET_VALUE, &hKEY))
12     {
13         if(ERROR_SUCCESS == RegSetValueEx(hKEY, "AutoShareWks", 0, REG_DWORD, (BYTE*)&dwShare, sizeof(DWORD)))
14         {
15             if(ERROR_SUCCESS == RegSetValueEx(hKEY, "AutoShareServer", 0, REG_DWORD, (BYTE*)&dwShare, sizeof(DWORD)))
16             {
17                 MessageBox(NULL, "关闭默认共享成功!", "提示:", MB_ICONEXCLAMATION);
18             }
19         }
20         else
21         {
22             MessageBox(NULL, "关闭默认共享失败!", "提示:", MB_ICONERROR);
23         }
24     }
25     RegCloseKey(hKEY);
26     
27     
28     HKEY hKEY1;
29     char *IPCPath = "SYSTEM\\CurrentControlSet\\Control\\Lsa";
30     DWORD dwIPC = 1;
31     
32     if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, IPCPath, 0, KEY_SET_VALUE, &hKEY1))
33     {
34         if(ERROR_SUCCESS == RegSetValueEx(hKEY1, "restrictanonymous", 0, REG_DWORD, (BYTE*)&dwIPC, sizeof(DWORD)))
35         {
36             MessageBox(NULL, "关闭 IPC 共享成功!", "提示:", MB_ICONEXCLAMATION);
37         }
38         else
39         {
40             MessageBox(NULL, "关闭 IPC 共享失败!", "提示:", MB_ICONERROR);
41         }
42     }
43     RegCloseKey(hKEY1);
44     return 0;
45 }

 

C++关闭默认共享

标签:show   mds   cmd   lsa   har   rev   cal   controls   turn   

原文地址:https://www.cnblogs.com/hoy0a1d/p/9257982.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!