Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

728 lines
20 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: dlgnew.cxx
  7. //
  8. // Contents: "New Share" dialog
  9. //
  10. // History: 21-Feb-95 BruceFo Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #include "headers.hxx"
  14. #pragma hdrstop
  15. #include "resource.h"
  16. #include "helpids.h"
  17. #include "dlgnew.hxx"
  18. #include "acl.hxx"
  19. #include "util.hxx"
  20. #include "shrinfo.hxx"
  21. ////////////////////////////////////////////////////////////////////////////
  22. ////////////////////////////////////////////////////////////////////////////
  23. //+-------------------------------------------------------------------------
  24. //
  25. // Member: CDlgNewShare::SizeWndProc, public
  26. //
  27. // Synopsis: "allow" edit window subclass proc to disallow non-numeric
  28. // characters.
  29. //
  30. // History: 5-Apr-95 BruceFo Created
  31. //
  32. //--------------------------------------------------------------------------
  33. LRESULT CALLBACK
  34. CDlgNewShare::SizeWndProc(
  35. IN HWND hwnd,
  36. IN UINT wMsg,
  37. IN WPARAM wParam,
  38. IN LPARAM lParam
  39. )
  40. {
  41. switch (wMsg)
  42. {
  43. case WM_CHAR:
  44. {
  45. WCHAR chCharCode = (WCHAR)wParam;
  46. if ( (chCharCode == TEXT('\t'))
  47. || (chCharCode == TEXT('\b'))
  48. || (chCharCode == TEXT('\n'))
  49. )
  50. {
  51. break;
  52. }
  53. if (chCharCode < TEXT('0') || chCharCode > TEXT('9'))
  54. {
  55. // bad key: ignore it
  56. MessageBeep(0xffffffff); // let user know it's an illegal char
  57. return FALSE;
  58. }
  59. break;
  60. }
  61. } // end of switch
  62. CDlgNewShare* pThis = (CDlgNewShare*)GetWindowLongPtr(GetParent(hwnd),GWLP_USERDATA);
  63. appAssert(NULL != pThis);
  64. return CallWindowProc(pThis->_pfnAllowProc, hwnd, wMsg, wParam, lParam);
  65. }
  66. //+-------------------------------------------------------------------------
  67. //
  68. // Method: CDlgNewShare::CDlgNewShare, private
  69. //
  70. // Synopsis: constructor
  71. //
  72. //--------------------------------------------------------------------------
  73. CDlgNewShare::CDlgNewShare(
  74. IN HWND hwndParent,
  75. IN PWSTR pszMachine
  76. )
  77. :
  78. CDialog(hwndParent, MAKEINTRESOURCE(IDD_NEW_SHARE)),
  79. _pszMachine(pszMachine),
  80. _bShareNameChanged(FALSE),
  81. _bPathChanged(FALSE),
  82. _bCommentChanged(FALSE),
  83. _wMaxUsers(DEFAULT_MAX_USERS),
  84. _fSecDescModified(FALSE),
  85. _pfnAllowProc(NULL),
  86. _pShareInfo(NULL)
  87. {
  88. INIT_SIG(CDlgNewShare);
  89. }
  90. //+-------------------------------------------------------------------------
  91. //
  92. // Method: CDlgNewShare::~CDlgNewShare, private
  93. //
  94. // Synopsis: destructor
  95. //
  96. //--------------------------------------------------------------------------
  97. CDlgNewShare::~CDlgNewShare()
  98. {
  99. CHECK_SIG(CDlgNewShare);
  100. delete _pShareInfo;
  101. _pShareInfo = NULL;
  102. }
  103. //+-------------------------------------------------------------------------
  104. //
  105. // Method: CDlgNewShare::DlgProc, private
  106. //
  107. // Synopsis: Dialog Procedure for this object
  108. //
  109. //--------------------------------------------------------------------------
  110. INT_PTR
  111. CDlgNewShare::DlgProc(
  112. IN HWND hwnd,
  113. IN UINT msg,
  114. IN WPARAM wParam,
  115. IN LPARAM lParam
  116. )
  117. {
  118. CHECK_SIG(CDlgNewShare);
  119. static DWORD aHelpIds[] =
  120. {
  121. IDOK, HC_OK,
  122. IDCANCEL, HC_CANCEL,
  123. IDC_SHARE_SHARENAME, HC_SHARE_SHARENAME,
  124. IDC_SHARE_PATH, HC_SHARE_PATH,
  125. IDC_SHARE_COMMENT, HC_SHARE_COMMENT,
  126. IDC_SHARE_MAXIMUM, HC_SHARE_MAXIMUM,
  127. IDC_SHARE_ALLOW, HC_SHARE_ALLOW,
  128. IDC_SHARE_ALLOW_VALUE, HC_SHARE_ALLOW_VALUE,
  129. IDC_SHARE_PERMISSIONS, HC_SHARE_PERMISSIONS,
  130. 0,0
  131. };
  132. switch (msg)
  133. {
  134. case WM_INITDIALOG:
  135. return _OnInitDialog(hwnd);
  136. case WM_COMMAND:
  137. return _OnCommand(hwnd, HIWORD(wParam), LOWORD(wParam), (HWND)lParam);
  138. case WM_VSCROLL:
  139. // The up/down control changed the edit control: select it again
  140. SendDlgItemMessage(hwnd, IDC_SHARE_ALLOW_VALUE, EM_SETSEL, 0, (LPARAM)-1);
  141. return TRUE;
  142. case WM_HELP:
  143. {
  144. LPHELPINFO lphi = (LPHELPINFO)lParam;
  145. if (lphi->iContextType == HELPINFO_WINDOW) // a control
  146. {
  147. WCHAR szHelp[50];
  148. LoadString(g_hInstance, IDS_HELPFILENAME, szHelp, ARRAYLEN(szHelp));
  149. WinHelp(
  150. (HWND)lphi->hItemHandle,
  151. szHelp,
  152. HELP_WM_HELP,
  153. (DWORD_PTR)aHelpIds);
  154. }
  155. break;
  156. }
  157. case WM_CONTEXTMENU:
  158. {
  159. WCHAR szHelp[50];
  160. LoadString(g_hInstance, IDS_HELPFILENAME, szHelp, ARRAYLEN(szHelp));
  161. WinHelp(
  162. (HWND)wParam,
  163. szHelp,
  164. HELP_CONTEXTMENU,
  165. (DWORD_PTR)aHelpIds);
  166. break;
  167. }
  168. case WM_DESTROY:
  169. {
  170. // restore original subclass to window.
  171. appAssert(NULL != GetDlgItem(hwnd,IDC_SHARE_ALLOW_VALUE));
  172. SetWindowLongPtr(GetDlgItem(hwnd,IDC_SHARE_ALLOW_VALUE), GWLP_WNDPROC, (LONG_PTR)_pfnAllowProc);
  173. return FALSE;
  174. }
  175. } // end of switch
  176. return FALSE;
  177. }
  178. //+-------------------------------------------------------------------------
  179. //
  180. // Method: CDlgNewShare::_OnInitDialog, private
  181. //
  182. // Synopsis: WM_INITDIALOG handler
  183. //
  184. //--------------------------------------------------------------------------
  185. BOOL
  186. CDlgNewShare::_OnInitDialog(
  187. IN HWND hwnd
  188. )
  189. {
  190. CHECK_SIG(CDlgNewShare);
  191. HRESULT hr;
  192. // for some reason, this dialog comes up on the bottom!
  193. // SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  194. // SetActiveWindow(hwnd);
  195. SetForegroundWindow(hwnd);
  196. // Use a trick from the property sheet code to properly place the dialog.
  197. // Basically, we want it to go wherever a new window would have gone, not
  198. // always in the upper-left corner of the screen. This avoids the problem
  199. // of multiple dialogs showing up in the same place on the screen,
  200. // overlapping each other.
  201. const TCHAR c_szStatic[] = TEXT("Static");
  202. HWND hwndT = CreateWindowEx(0, c_szStatic, NULL,
  203. WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT,
  204. 0, 0, NULL, NULL, g_hInstance, NULL);
  205. if (hwndT)
  206. {
  207. RECT rc;
  208. GetWindowRect(hwndT, &rc);
  209. DestroyWindow(hwndT);
  210. SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
  211. }
  212. SetDialogIconBig(hwnd, IDI_SHARESFLD);
  213. SetDialogIconSmall(hwnd, IDI_SHARESFLD);
  214. // storage for security descriptor
  215. _pShareInfo = new CShareInfo();
  216. if (NULL == _pShareInfo)
  217. {
  218. return FALSE;
  219. }
  220. hr = _pShareInfo->InitInstance();
  221. CHECK_HRESULT(hr);
  222. if (FAILED(hr))
  223. {
  224. delete _pShareInfo;
  225. return FALSE;
  226. }
  227. // Subclass allow edit control to disallow non-positive numbers
  228. _pfnAllowProc = (WNDPROC)SetWindowLongPtr(
  229. GetDlgItem(hwnd, IDC_SHARE_ALLOW_VALUE),
  230. GWLP_WNDPROC,
  231. (LONG_PTR)&SizeWndProc);
  232. // use LanMan API constants to set maximum share name & comment lengths
  233. SendDlgItemMessage(hwnd, IDC_SHARE_SHARENAME, EM_LIMITTEXT, NNLEN, 0L);
  234. SendDlgItemMessage(hwnd, IDC_SHARE_PATH, EM_LIMITTEXT, MAX_PATH-1, 0L);
  235. SendDlgItemMessage(hwnd, IDC_SHARE_COMMENT, EM_LIMITTEXT, MAXCOMMENTSZ, 0L);
  236. CheckRadioButton(
  237. hwnd,
  238. IDC_SHARE_MAXIMUM,
  239. IDC_SHARE_ALLOW,
  240. IDC_SHARE_MAXIMUM);
  241. SetDlgItemText(hwnd, IDC_SHARE_ALLOW_VALUE, L"");
  242. // set the spin control range: 1 <--> large number
  243. SendDlgItemMessage(
  244. hwnd,
  245. IDC_SHARE_ALLOW_SPIN,
  246. UDM_SETRANGE,
  247. 0,
  248. MAKELONG(g_uiMaxUsers, 1));
  249. SetFocus(GetDlgItem(hwnd, IDC_SHARE_SHARENAME));
  250. return FALSE;
  251. }
  252. //+-------------------------------------------------------------------------
  253. //
  254. // Member: CDlgNewShare::_OnCommand, private
  255. //
  256. // Synopsis: WM_COMMAND handler
  257. //
  258. // History: 21-Apr-95 BruceFo Created
  259. //
  260. //--------------------------------------------------------------------------
  261. BOOL
  262. CDlgNewShare::_OnCommand(
  263. IN HWND hwnd,
  264. IN WORD wNotifyCode,
  265. IN WORD wID,
  266. IN HWND hwndCtl
  267. )
  268. {
  269. CHECK_SIG(CDlgNewShare);
  270. switch (wID)
  271. {
  272. //
  273. // Notifications
  274. //
  275. case IDC_SHARE_MAXIMUM:
  276. if (BN_CLICKED == wNotifyCode)
  277. {
  278. // Take away WS_TABSTOP from the "allow users" edit control
  279. HWND hwndEdit = GetDlgItem(hwnd, IDC_SHARE_ALLOW_VALUE);
  280. SetWindowLong(hwndEdit, GWL_STYLE, GetWindowLong(hwndEdit, GWL_STYLE) & ~WS_TABSTOP);
  281. _CacheMaxUses(hwnd);
  282. SetDlgItemText(hwnd, IDC_SHARE_ALLOW_VALUE, L"");
  283. }
  284. return TRUE;
  285. case IDC_SHARE_ALLOW:
  286. if (BN_CLICKED == wNotifyCode)
  287. {
  288. // Give WS_TABSTOP to the "allow users" edit control
  289. HWND hwndEdit = GetDlgItem(hwnd, IDC_SHARE_ALLOW_VALUE);
  290. SetWindowLong(hwndEdit, GWL_STYLE, GetWindowLong(hwndEdit, GWL_STYLE) | WS_TABSTOP);
  291. // let the spin control set the edit control
  292. SendDlgItemMessage(hwnd, IDC_SHARE_ALLOW_SPIN, UDM_SETPOS, 0, MAKELONG(_wMaxUsers, 0));
  293. SendDlgItemMessage(hwnd, IDC_SHARE_ALLOW_VALUE, EM_SETSEL, 0, (LPARAM)-1);
  294. }
  295. return TRUE;
  296. case IDC_SHARE_ALLOW_VALUE:
  297. {
  298. if (EN_SETFOCUS == wNotifyCode)
  299. {
  300. if (1 != IsDlgButtonChecked(hwnd, IDC_SHARE_ALLOW))
  301. {
  302. CheckRadioButton(
  303. hwnd,
  304. IDC_SHARE_MAXIMUM,
  305. IDC_SHARE_ALLOW,
  306. IDC_SHARE_ALLOW);
  307. }
  308. // let the spin control set the edit control
  309. SendDlgItemMessage(hwnd, IDC_SHARE_ALLOW_SPIN, UDM_SETPOS, 0, MAKELONG(_wMaxUsers, 0));
  310. SendDlgItemMessage(hwnd, IDC_SHARE_ALLOW_VALUE, EM_SETSEL, 0, (LPARAM)-1);
  311. }
  312. if (EN_KILLFOCUS == wNotifyCode)
  313. {
  314. _CacheMaxUses(hwnd);
  315. }
  316. return TRUE;
  317. }
  318. case IDC_SHARE_ALLOW_SPIN:
  319. if (UDN_DELTAPOS == wNotifyCode)
  320. {
  321. if (1 != IsDlgButtonChecked(hwnd, IDC_SHARE_ALLOW))
  322. {
  323. CheckRadioButton(
  324. hwnd,
  325. IDC_SHARE_MAXIMUM,
  326. IDC_SHARE_ALLOW,
  327. IDC_SHARE_ALLOW);
  328. }
  329. }
  330. return TRUE;
  331. case IDC_SHARE_SHARENAME:
  332. {
  333. if (wNotifyCode == EN_CHANGE)
  334. {
  335. _bShareNameChanged = TRUE;
  336. }
  337. return TRUE;
  338. }
  339. case IDC_SHARE_PATH:
  340. {
  341. if (wNotifyCode == EN_CHANGE)
  342. {
  343. _bPathChanged = TRUE;
  344. }
  345. return TRUE;
  346. }
  347. case IDC_SHARE_COMMENT:
  348. {
  349. if (wNotifyCode == EN_CHANGE)
  350. {
  351. _bCommentChanged = TRUE;
  352. }
  353. return TRUE;
  354. }
  355. //
  356. // Commands
  357. //
  358. case IDOK:
  359. return _OnOK(hwnd);
  360. case IDCANCEL:
  361. EndDialog(hwnd, FALSE);
  362. return TRUE;
  363. case IDC_SHARE_PERMISSIONS:
  364. return _OnPermissions(hwnd);
  365. } // end of switch (wID)
  366. return FALSE;
  367. }
  368. //+-------------------------------------------------------------------------
  369. //
  370. // Method: CDlgNewShare::_OnOK, private
  371. //
  372. // Synopsis:
  373. //
  374. //--------------------------------------------------------------------------
  375. BOOL
  376. CDlgNewShare::_OnOK(
  377. IN HWND hwnd
  378. )
  379. {
  380. CHECK_SIG(CDlgNewShare);
  381. HRESULT hr;
  382. HRESULT uTemp;
  383. BOOL fSpecial = FALSE; // IPC$ or ADMIN$
  384. // Validate the share
  385. WCHAR szShareName[NNLEN + 1];
  386. if (0 == GetDlgItemText(hwnd, IDC_SHARE_SHARENAME, szShareName, ARRAYLEN(szShareName)))
  387. {
  388. MyErrorDialog(hwnd, IERR_BlankShareName);
  389. SetErrorFocus(hwnd, IDC_SHARE_SHARENAME);
  390. return TRUE;
  391. }
  392. TrimLeadingAndTrailingSpaces(szShareName);
  393. WCHAR szPath[MAX_PATH];
  394. GetDlgItemText(hwnd, IDC_SHARE_PATH, szPath, ARRAYLEN(szPath));
  395. // Trying to create a reserved share?
  396. if ( (0 == _wcsicmp(g_szIpcShare, szShareName))
  397. || (0 == _wcsicmp(g_szAdminShare, szShareName)))
  398. {
  399. // We will let you add IPC$ and ADMIN$ as long as there is no
  400. // path specified.
  401. if (szPath[0] != TEXT('\0'))
  402. {
  403. MyErrorDialog(hwnd, MSG_ADDSPECIAL);
  404. SetErrorFocus(hwnd, IDC_SHARE_PATH);
  405. return TRUE;
  406. }
  407. fSpecial = TRUE;
  408. }
  409. else if (!IsValidShareName(szShareName, &uTemp))
  410. {
  411. MyErrorDialog(hwnd, uTemp);
  412. SetErrorFocus(hwnd, IDC_SHARE_SHARENAME);
  413. return TRUE;
  414. }
  415. // If the user entered some ACL, warn them that we're going to nuke
  416. // it and let the system use its default (since special shares can't
  417. // have their security set).
  418. if (fSpecial || DriveLetterShare(szShareName))
  419. {
  420. if (_fSecDescModified)
  421. {
  422. DWORD id = MyConfirmationDialog(
  423. hwnd,
  424. MSG_NOSECURITYONSPECIAL,
  425. MB_YESNO | MB_ICONEXCLAMATION);
  426. if (id == IDNO)
  427. {
  428. SetErrorFocus(hwnd, IDC_SHARE_SHARENAME);
  429. return TRUE;
  430. }
  431. _pShareInfo->TransferSecurityDescriptor(NULL);
  432. }
  433. }
  434. // Check to see that the same share isn't already used, for either the
  435. // same path or for another path.
  436. SHARE_INFO_2* info2;
  437. NET_API_STATUS ret = NetShareGetInfo(_pszMachine, szShareName, 2, (LPBYTE*)&info2);
  438. if (ret == NERR_Success)
  439. {
  440. // It is already shared. Trying to re-share IPC$ or ADMIN$?
  441. if (fSpecial)
  442. {
  443. MyErrorDialog(hwnd, IERR_AlreadyExistsSpecial, szShareName);
  444. SetErrorFocus(hwnd, IDC_SHARE_SHARENAME);
  445. NetApiBufferFree(info2);
  446. return TRUE;
  447. }
  448. // Is it already shared for the same path?
  449. if (0 == _wcsicmp(info2->shi2_path, szPath))
  450. {
  451. MyErrorDialog(hwnd, IERR_AlreadyExists, szShareName);
  452. SetErrorFocus(hwnd, IDC_SHARE_SHARENAME);
  453. NetApiBufferFree(info2);
  454. return TRUE;
  455. }
  456. // Shared for a different path. Ask the user if they wish to delete
  457. // the old share and create the new one using the name.
  458. DWORD id = ConfirmReplaceShare(hwnd, szShareName, info2->shi2_path, szPath);
  459. if (id == IDNO)
  460. {
  461. SetErrorFocus(hwnd, IDC_SHARE_SHARENAME);
  462. NetApiBufferFree(info2);
  463. return TRUE;
  464. }
  465. else if (id == IDCANCEL)
  466. {
  467. EndDialog(hwnd, FALSE);
  468. NetApiBufferFree(info2);
  469. return TRUE;
  470. }
  471. // User said to replace the old share. Do it.
  472. ret = NetShareDel(_pszMachine, szShareName, 0);
  473. if (ret != NERR_Success)
  474. {
  475. DisplayError(hwnd, IERR_CANT_DEL_SHARE, ret, szShareName);
  476. NetApiBufferFree(info2);
  477. return FALSE;
  478. }
  479. else
  480. {
  481. SHChangeNotify(SHCNE_NETUNSHARE, SHCNF_PATH, info2->shi2_path, NULL);
  482. }
  483. NetApiBufferFree(info2);
  484. }
  485. if (!fSpecial)
  486. {
  487. // Check for downlevel accessibility
  488. // CODEWORK we should really get rid of this at some point -- JonN 7/18/97
  489. ULONG nType;
  490. if (NERR_Success != NetpPathType(NULL, szShareName, &nType, INPT_FLAGS_OLDPATHS))
  491. {
  492. DWORD id = MyConfirmationDialog(
  493. hwnd,
  494. IERR_InaccessibleByDos,
  495. MB_YESNO | MB_ICONEXCLAMATION,
  496. szShareName);
  497. if (id == IDNO)
  498. {
  499. SetErrorFocus(hwnd, IDC_SHARE_SHARENAME);
  500. return TRUE;
  501. }
  502. }
  503. }
  504. // Everything OK, save away the data
  505. if (_bShareNameChanged)
  506. {
  507. hr = _pShareInfo->SetNetname(szShareName);
  508. CHECK_HRESULT(hr);
  509. }
  510. if (_bPathChanged)
  511. {
  512. hr = _pShareInfo->SetPath(szPath);
  513. CHECK_HRESULT(hr);
  514. }
  515. if (_bCommentChanged)
  516. {
  517. WCHAR szComment[MAXCOMMENTSZ + 1];
  518. GetDlgItemText(hwnd, IDC_SHARE_COMMENT, szComment, ARRAYLEN(szComment));
  519. hr = _pShareInfo->SetRemark(szComment);
  520. CHECK_HRESULT(hr);
  521. }
  522. if (1 == IsDlgButtonChecked(hwnd, IDC_SHARE_MAXIMUM))
  523. {
  524. hr = _pShareInfo->SetMaxUses(SHI_USES_UNLIMITED);
  525. CHECK_HRESULT(hr);
  526. }
  527. else if (1 == IsDlgButtonChecked(hwnd, IDC_SHARE_ALLOW))
  528. {
  529. _CacheMaxUses(hwnd);
  530. hr = _pShareInfo->SetMaxUses(_wMaxUsers);
  531. CHECK_HRESULT(hr);
  532. }
  533. _pShareInfo->SetDirtyFlag(SHARE_FLAG_ADDED);
  534. ret = _pShareInfo->Commit(_pszMachine);
  535. if (ret != NERR_Success)
  536. {
  537. DisplayError(hwnd, IERR_CANT_ADD_SHARE, ret, _pShareInfo->GetNetname());
  538. }
  539. if (fSpecial)
  540. {
  541. // IPC$ doesn't have a path. ADMIN$ does, but we need to get it: we
  542. // create the share passing in no path, as required by the API, but
  543. // then we ask the server what it decided to share it as.
  544. if (0 == _wcsicmp(g_szAdminShare, szShareName))
  545. {
  546. SHARE_INFO_2* info2;
  547. NET_API_STATUS ret = NetShareGetInfo(_pszMachine, szShareName, 2, (LPBYTE*)&info2);
  548. if (ret == NERR_Success)
  549. {
  550. SHChangeNotify(SHCNE_NETSHARE, SHCNF_PATH, info2->shi2_path, NULL);
  551. NetApiBufferFree(info2);
  552. }
  553. // else... oh well. No notification to the shell.
  554. }
  555. }
  556. else
  557. {
  558. SHChangeNotify(SHCNE_NETSHARE, SHCNF_PATH, _pShareInfo->GetPath(), NULL);
  559. }
  560. EndDialog(hwnd, TRUE);
  561. return TRUE;
  562. }
  563. //+-------------------------------------------------------------------------
  564. //
  565. // Method: CDlgNewShare::_OnPermissions, private
  566. //
  567. // Synopsis:
  568. //
  569. //--------------------------------------------------------------------------
  570. BOOL
  571. CDlgNewShare::_OnPermissions(
  572. IN HWND hwnd
  573. )
  574. {
  575. CHECK_SIG(CDlgNewShare);
  576. WCHAR szShareName[NNLEN + 1];
  577. GetDlgItemText(hwnd, IDC_SHARE_SHARENAME, szShareName, ARRAYLEN(szShareName));
  578. // don't trim spaces, this might be an existing share with spaces in its name
  579. PSECURITY_DESCRIPTOR pNewSecDesc = NULL;
  580. PSECURITY_DESCRIPTOR pSecDesc = _pShareInfo->GetSecurityDescriptor();
  581. appAssert(NULL == pSecDesc || IsValidSecurityDescriptor(pSecDesc));
  582. BOOL bSecDescChanged;
  583. LONG err = EditShareAcl(
  584. hwnd,
  585. _pszMachine,
  586. szShareName,
  587. pSecDesc,
  588. &bSecDescChanged,
  589. &pNewSecDesc);
  590. if (bSecDescChanged)
  591. {
  592. _fSecDescModified = TRUE;
  593. appAssert(IsValidSecurityDescriptor(pNewSecDesc));
  594. _pShareInfo->TransferSecurityDescriptor(pNewSecDesc);
  595. }
  596. return TRUE;
  597. }
  598. //+-------------------------------------------------------------------------
  599. //
  600. // Method: CDlgNewShare::_CacheMaxUses, private
  601. //
  602. // Synopsis:
  603. //
  604. //--------------------------------------------------------------------------
  605. VOID
  606. CDlgNewShare::_CacheMaxUses(
  607. IN HWND hwnd
  608. )
  609. {
  610. DWORD dwRet = (DWORD)SendDlgItemMessage(hwnd, IDC_SHARE_ALLOW_SPIN, UDM_GETPOS, 0, 0);
  611. if (HIWORD(dwRet) != 0)
  612. {
  613. _wMaxUsers = DEFAULT_MAX_USERS;
  614. // Reset the edit control to the new value
  615. SendDlgItemMessage(hwnd, IDC_SHARE_ALLOW_SPIN, UDM_SETPOS, 0, MAKELONG(_wMaxUsers, 0));
  616. SendDlgItemMessage(hwnd, IDC_SHARE_ALLOW_VALUE, EM_SETSEL, 0, (LPARAM)-1);
  617. }
  618. else
  619. {
  620. _wMaxUsers = LOWORD(dwRet);
  621. }
  622. }