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.

1828 lines
71 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. ShareNet.C
  5. Abstract:
  6. File copy and sharing dialog
  7. Author:
  8. Bob Watson (a-robw)
  9. Revision History:
  10. 17 Feb 94 Written
  11. --*/
  12. //
  13. // Windows Include Files
  14. //
  15. #include <windows.h>
  16. #include <stdio.h>
  17. #include <malloc.h>
  18. #include <tchar.h> // unicode macros
  19. #include <stdlib.h> // string to number conversions
  20. #include <lmcons.h> // lanman API constants
  21. //
  22. // app include files
  23. //
  24. #include "otnboot.h"
  25. #include "otnbtdlg.h"
  26. //
  27. // local windows messages
  28. //
  29. #define NCDU_SHARE_DIR (WM_USER +101)
  30. #define NCDU_VALIDATE_AND_END (WM_USER +103)
  31. #define NCDU_BROWSE_DIST_PATH (WM_USER +104)
  32. #define NCDU_BROWSE_DEST_PATH (WM_USER +105)
  33. //
  34. // static variables
  35. //
  36. //
  37. static int nNextDialog; // select dialog to follow this on OK
  38. static BOOL bShareNotCopy; // select default button mode
  39. //
  40. // these variables are used to remember the contents of the edit controls
  41. // that are disabled and/or blanked
  42. //
  43. static TCHAR szShareName1[MAX_PATH];
  44. static TCHAR szDestPath[MAX_PATH];
  45. static TCHAR szShareName2[MAX_PATH];
  46. static TCHAR szServerName[MAX_PATH];
  47. static TCHAR szShareName3[MAX_PATH];
  48. #ifdef TERMSRV
  49. extern TCHAR szCommandLineVal[MAX_PATH];
  50. #endif // TERMSRV
  51. static
  52. LPCTSTR
  53. GetDefaultDestPath (
  54. VOID
  55. )
  56. /*++
  57. Routine Description:
  58. Creates a valid path to use as the default destination to copy the
  59. client files to from the CD. The routine finds the first valid
  60. local drive, then on that drive, finds the first permutation of
  61. "Clients" or "Clients[0-9]" that isn't currently on that drive.
  62. Arguments:
  63. None
  64. Return Value:
  65. Pointer to the read only string containing the resulting path or
  66. an empty string if a valid path could not be concocted.
  67. --*/
  68. {
  69. static TCHAR szPathBuffer[MAX_PATH];
  70. BOOL bFound;
  71. UINT nDriveType;
  72. DWORD dwFileAttrib;
  73. LPTSTR szUniqueChar;
  74. // start by finding a valid disk drive
  75. szPathBuffer[0] = cC;
  76. szPathBuffer[1] = cColon;
  77. szPathBuffer[2] = cBackslash;
  78. szPathBuffer[3] = 0;
  79. bFound = FALSE;
  80. while (!bFound) {
  81. nDriveType = GetDriveType (szPathBuffer);
  82. if (nDriveType == DRIVE_FIXED) {
  83. bFound = TRUE;
  84. } else {
  85. // increment drive letter
  86. szPathBuffer[0]++;
  87. if (szPathBuffer[0] > cZ) break;
  88. }
  89. }
  90. if (!bFound) {
  91. // unable to find a suitable drive so bail out.
  92. szPathBuffer[0] = 0;
  93. } else {
  94. // found a suitable drive so add a directory
  95. lstrcat (szPathBuffer, cszClientsDir);
  96. szUniqueChar = &szPathBuffer[lstrlen(szPathBuffer)];
  97. *(szUniqueChar + 1) = 0; // add extra null char
  98. bFound = FALSE;
  99. while (!bFound) {
  100. // the path is "found" when it references a non-
  101. // existent directory
  102. dwFileAttrib = QuietGetFileAttributes (szPathBuffer);
  103. if (dwFileAttrib == 0xFFFFFFFF) {
  104. bFound = TRUE;
  105. } else {
  106. if (*szUniqueChar == 0) {
  107. *szUniqueChar = c0;
  108. } else {
  109. if (*szUniqueChar < c9) {
  110. *szUniqueChar += 1; // increment digit
  111. } else {
  112. // used up all the letters with out finding an
  113. // unused dir so return an empty string
  114. szPathBuffer [0] = 0;
  115. break;
  116. }
  117. }
  118. }
  119. }
  120. }
  121. return (LPCTSTR)&szPathBuffer[0];
  122. }
  123. static
  124. LPCTSTR
  125. GetDefaultShareName (
  126. IN LPCTSTR szServer
  127. )
  128. /*++
  129. Routine Description:
  130. Creates a share name to be used as a default share. If an unused
  131. name can be created, then it is returned, if all names are used,
  132. then an empty string is returned.
  133. Arguments:
  134. IN LPCTSTR szServer pointer to the buffer containing the name of
  135. the server on which to look up the share name.
  136. if this parameter is NULL, then the local
  137. machine is used.
  138. Return Value:
  139. the pointer to a read-only buffer containing either the name of an
  140. unused share point or an empty string if such a name cannot be
  141. created.
  142. --*/
  143. {
  144. static TCHAR szNameBuffer[MAX_PATH];
  145. LPTSTR szLocalPath;
  146. LPTSTR szShareName;
  147. LPTSTR szShareIndex;
  148. TCHAR cOrigIndexChar;
  149. DWORD dwBufLen;
  150. DWORD dwFileAttrib;
  151. BOOL bFound;
  152. // allocate a local buffer for building dir path in
  153. szLocalPath = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  154. if (szLocalPath == NULL) {
  155. // unable to allocate mem for local path buffer so return an
  156. // empty string and leave
  157. szNameBuffer[0] = 0;
  158. } else {
  159. // build a UNC path in the local buffer to test for the
  160. // existence of the share point
  161. *szLocalPath = 0;
  162. lstrcpy (szLocalPath, cszDoubleBackslash);
  163. if (szServer == NULL) {
  164. // then look up local computer name
  165. dwBufLen = MAX_COMPUTERNAME_LENGTH+1;
  166. GetComputerName (&szLocalPath[2], &dwBufLen);
  167. } else {
  168. // use server sent in path
  169. lstrcat (szLocalPath, szServer);
  170. }
  171. lstrcat (szLocalPath, cszBackslash);
  172. // save pointer to sharepoint name in UNC string
  173. szShareName = &szLocalPath[lstrlen(szLocalPath)];
  174. lstrcpy (szShareName, GetStringResource (CSZ_DEFAULT_CLIENT_SHARE));
  175. // limit name to 8 characters
  176. if (lstrlen(szShareName) > 8) {
  177. szShareName[8] = 0;
  178. }
  179. // for uniqueness, count the last digit from 0 - 9
  180. if (lstrlen(szShareName) >= 7) {
  181. // overwrite the last character
  182. szShareIndex = &szShareName[7];
  183. cOrigIndexChar = *szShareIndex;
  184. } else {
  185. szShareIndex = &szShareName[lstrlen(szShareName)];
  186. cOrigIndexChar = 0;
  187. }
  188. *(szShareIndex + 1) = 0; // add extra terminating null char
  189. bFound = FALSE;
  190. while (!bFound) {
  191. dwFileAttrib = QuietGetFileAttributes (szLocalPath);
  192. if (dwFileAttrib == 0xFFFFFFFF) {
  193. bFound = TRUE;
  194. } else {
  195. // this share point already exists, so try the
  196. // next one in the sequence
  197. if (*szShareIndex == cOrigIndexChar) {
  198. // this is the first retry
  199. *szShareIndex = c0;
  200. } else {
  201. if (*szShareIndex < c9) {
  202. *szShareIndex += 1; // increment character
  203. } else {
  204. // all attempted names are in use so bail out with
  205. // an empty buffer
  206. break;
  207. }
  208. }
  209. }
  210. }
  211. if (bFound) {
  212. // copy server name to output buffer
  213. lstrcpy (szNameBuffer, szShareName);
  214. } else {
  215. // a valid unused share name wasn't found, so return empty buffer
  216. szNameBuffer[0] = 0;
  217. }
  218. FREE_IF_ALLOC (szLocalPath);
  219. }
  220. return (LPCTSTR)&szNameBuffer[0];
  221. }
  222. static
  223. DWORD
  224. UpdateDiskSpace (
  225. IN HWND hwndDlg
  226. )
  227. /*++
  228. Routine Description:
  229. Computes and display the total estimated disk space required
  230. to copy the network utilities as read from the .INF
  231. Arguments:
  232. IN HWND hwndDlg
  233. Return Value:
  234. total bytes required as read from the INI
  235. --*/
  236. {
  237. DWORD dwBytesReqd = 0;
  238. LPTSTR szFileInfo;
  239. LPTSTR szInfName;
  240. szFileInfo = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  241. szInfName = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  242. if ((szFileInfo != NULL) && (szInfName != NULL)) {
  243. GetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, szInfName, MAX_PATH);
  244. if (szInfName[lstrlen(szInfName)-1] != cBackslash) lstrcat(szInfName, cszBackslash);
  245. lstrcat (szInfName, cszAppInfName);
  246. QuietGetPrivateProfileString (cszSizes, csz_ClientTree_, cszEmptyString,
  247. szFileInfo, MAX_PATH, szInfName);
  248. dwBytesReqd = GetSizeFromInfString (szFileInfo);
  249. // reuse InfName buffer for output string
  250. // add 500,000 to bytes rquired in order to round M's up. (div
  251. // will simply truncate)
  252. _stprintf (szInfName,
  253. GetStringResource (FMT_M_BYTES),
  254. ((dwBytesReqd+500000)/1000000));
  255. SetDlgItemText (hwndDlg, NCDU_DISK_SPACE_REQD, szInfName);
  256. }
  257. FREE_IF_ALLOC(szFileInfo);
  258. FREE_IF_ALLOC(szInfName);
  259. return dwBytesReqd;
  260. }
  261. static
  262. VOID
  263. UpdateDialogMode (
  264. IN HWND hwndDlg
  265. )
  266. /*++
  267. Routine Description:
  268. Called to size the dialog box based on the currently selected
  269. mode. If the "Use existing share" mode is selected, then
  270. only the top half of the dialog box is visible, if the
  271. "copy" mode is selected then the entire dialog box is
  272. visible. All concealed controls are disabled for proper
  273. tab sequencing.
  274. Arguments:
  275. IN HWND hwndDlg
  276. Return Value:
  277. None
  278. --*/
  279. {
  280. BOOL bUseExistingPath;
  281. BOOL bShareFiles;
  282. BOOL bCopyAndShare;
  283. BOOL bUseExistingShare;
  284. BOOL bEnablePath;
  285. // save any share/path information in case the fields have to be cleared
  286. EnableWindow (GetDlgItem (hwndDlg, NCDU_FILES_ALREADY_SHARED), TRUE);
  287. if ( SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH, WM_GETTEXTLENGTH, 0, 0) > 0) {
  288. GetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, szDestPath, MAX_PATH);
  289. }
  290. if ( SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1, WM_GETTEXTLENGTH, 0, 0) > 0) {
  291. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, szShareName1, MAX_PATH);
  292. }
  293. if ( SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_2, WM_GETTEXTLENGTH, 0, 0) > 0) {
  294. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2, szShareName2, MAX_PATH);
  295. }
  296. if ( SendDlgItemMessage (hwndDlg, NCDU_SERVER_NAME, WM_GETTEXTLENGTH, 0, 0) > 0) {
  297. GetDlgItemText (hwndDlg, NCDU_SERVER_NAME, szServerName, MAX_PATH);
  298. }
  299. if ( SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_3, WM_GETTEXTLENGTH, 0, 0) > 0) {
  300. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3, szShareName3, MAX_PATH);
  301. }
  302. // buttons are mutually exclusive so only one of these can (should) be
  303. // true at a time
  304. bUseExistingPath =
  305. (BOOL)(IsDlgButtonChecked(hwndDlg, NCDU_USE_DIST_PATH) == CHECKED);
  306. bShareFiles =
  307. (BOOL)(IsDlgButtonChecked(hwndDlg, NCDU_USE_EXISTING_SHARE) == CHECKED);
  308. bCopyAndShare =
  309. (BOOL)(IsDlgButtonChecked(hwndDlg, NCDU_COPY_AND_MAKE_SHARE) == CHECKED);
  310. bUseExistingShare =
  311. (BOOL)(IsDlgButtonChecked(hwndDlg, NCDU_FILES_ALREADY_SHARED) == CHECKED);
  312. bEnablePath = !bUseExistingShare;
  313. // set the dialog to be approrpriate for the current button
  314. // set the path edit controls
  315. EnableWindow (GetDlgItem (hwndDlg, NCDU_TOP_PATH_TITLE), bEnablePath);
  316. EnableWindow (GetDlgItem (hwndDlg, NCDU_DISTRIBUTION_PATH), bEnablePath);
  317. EnableWindow (GetDlgItem (hwndDlg, NCDU_BROWSE_DIST), bEnablePath);
  318. // set the "Share Files" controls
  319. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_FILES_TEXT), bShareFiles);
  320. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1_TITLE), bShareFiles);
  321. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1), bShareFiles);
  322. if (bShareFiles) {
  323. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, szShareName1);
  324. } else {
  325. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, cszEmptyString);
  326. }
  327. // set the "Copy Files..." controls
  328. EnableWindow (GetDlgItem (hwndDlg, NCDU_DISK_SPACE_REQD), bCopyAndShare);
  329. EnableWindow (GetDlgItem (hwndDlg, NCDU_DISK_SPACE_REQD_LABEL), bCopyAndShare);
  330. EnableWindow (GetDlgItem (hwndDlg, NCDU_DESTINATION_PATH_LABEL), bCopyAndShare);
  331. EnableWindow (GetDlgItem (hwndDlg, NCDU_DESTINATION_PATH), bCopyAndShare);
  332. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_2_TITLE), bCopyAndShare);
  333. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_2), bCopyAndShare);
  334. if (bCopyAndShare) {
  335. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, szDestPath);
  336. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2, szShareName2);
  337. } else {
  338. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, cszEmptyString);
  339. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2, cszEmptyString);
  340. }
  341. // set "Use Existing Share..." controls
  342. EnableWindow (GetDlgItem (hwndDlg, NCDU_SERVER_NAME_TITLE), bUseExistingShare);
  343. EnableWindow (GetDlgItem (hwndDlg, NCDU_SERVER_NAME), bUseExistingShare);
  344. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_3_TITLE), bUseExistingShare);
  345. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_3), bUseExistingShare);
  346. if (bUseExistingShare) {
  347. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME, szServerName);
  348. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3, szShareName3);
  349. } else {
  350. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME, cszEmptyString);
  351. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3, cszEmptyString);
  352. }
  353. // redraw button box
  354. UpdateWindow (hwndDlg);
  355. }
  356. static
  357. BOOL
  358. CopyFilesFromDistToDest (
  359. IN HWND hwndDlg
  360. )
  361. /*++
  362. Routine Description:
  363. copies all clients listed under the distribution directory
  364. to the destination directory.
  365. Arguments:
  366. IN HWND hwndDlg
  367. handle to dialog box window
  368. Return Value:
  369. TRUE if all went ok
  370. FALSE if the operation was aborted or ended in error.
  371. --*/
  372. {
  373. LPTSTR szSourceDir;
  374. LPTSTR szDestDir;
  375. DWORD dwBytesReqd = 0;
  376. LPTSTR szFileInfo;
  377. DWORD dwCopyFlags = CD_FLAGS_COPY_SUB_DIR + CD_FLAGS_LONG_NAMES;
  378. LPTSTR szClientName;
  379. LPTSTR szInfName;
  380. LPTSTR mszDirList;
  381. LPTSTR szDisplayString;
  382. LPTSTR szThisDir;
  383. DWORD dwFileAttrib;
  384. int nCopyResult;
  385. CF_DLG_DATA cfData;
  386. szSourceDir = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  387. szDestDir = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  388. szFileInfo = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  389. szClientName = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  390. szInfName = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  391. mszDirList = GlobalAlloc (GPTR, MEDIUM_BUFFER_SIZE * sizeof(TCHAR));
  392. if ((szSourceDir != NULL) &&
  393. (szDestDir != NULL) &&
  394. (szFileInfo != NULL) &&
  395. (szClientName != NULL) &&
  396. (mszDirList != NULL) &&
  397. (szInfName != NULL)){
  398. // copy files from root dir only first
  399. lstrcpy (szClientName, GetStringResource (FMT_CLIENT_INFO_DISPLAY));
  400. cfData.szDisplayName = szClientName;
  401. cfData.szSourceDir = pAppInfo->szDistShowPath;
  402. cfData.szDestDir = pAppInfo->szDestPath;
  403. cfData.dwCopyFlags = CD_FLAGS_LONG_NAMES;
  404. cfData.dwTotalSize = 0;
  405. cfData.dwFilesCopied = 0;
  406. cfData.dwDirsCreated = 0;
  407. nCopyResult = (int)DialogBoxParam (
  408. (HANDLE)GetWindowLongPtr(GetParent(hwndDlg), GWLP_HINSTANCE),
  409. MAKEINTRESOURCE(NCDU_COPYING_FILES_DLG),
  410. hwndDlg,
  411. CopyFileDlgProc,
  412. (LPARAM)&cfData);
  413. // go through list of client software to copy an and copy the
  414. // selected ones
  415. lstrcpy (szInfName, pAppInfo->szDistShowPath);
  416. if (szInfName[lstrlen(szInfName)-1] != cBackslash) lstrcat(szInfName, cszBackslash);
  417. lstrcat (szInfName, cszAppInfName);
  418. // get list of keys under the [CopyClients] section
  419. CLEAR_FIRST_FOUR_BYTES (mszDirList);
  420. QuietGetPrivateProfileString (cszCopyClients, NULL, cszEmptyString,
  421. mszDirList, MEDIUM_BUFFER_SIZE, szInfName);
  422. for (szThisDir = mszDirList;
  423. (*szThisDir != 0) && (nCopyResult == IDOK);
  424. szThisDir += lstrlen(szThisDir) + 1) {
  425. // make dir path for this dir & copy the files if valid
  426. lstrcpy (szSourceDir, pAppInfo->szDistShowPath);
  427. if (szSourceDir[lstrlen(szSourceDir)-1] != cBackslash) lstrcat (szSourceDir, cszBackslash);
  428. lstrcat (szSourceDir, szThisDir);
  429. dwFileAttrib = QuietGetFileAttributes (szSourceDir);
  430. // if the resulting source path is a directory then copy it to the
  431. // destination path
  432. if ((dwFileAttrib != 0xFFFFFFFF) &&
  433. ((dwFileAttrib & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)) {
  434. // make dest path
  435. lstrcpy (szDestDir, pAppInfo->szDestPath);
  436. if (szDestDir[lstrlen(szDestDir)-1] != cBackslash) lstrcat (szDestDir, cszBackslash);
  437. lstrcat (szDestDir, szThisDir);
  438. // copy files
  439. QuietGetPrivateProfileString (cszCopyClients, szThisDir, cszEmptyString,
  440. szClientName, MAX_PATH, szInfName);
  441. cfData.szDisplayName = szClientName;
  442. cfData.szSourceDir = szSourceDir;
  443. cfData.szDestDir = szDestDir;
  444. cfData.dwCopyFlags = CD_FLAGS_COPY_SUB_DIR | CD_FLAGS_LONG_NAMES;
  445. QuietGetPrivateProfileString (cszSizes, szThisDir, cszEmptyString,
  446. szFileInfo, MAX_PATH, szInfName);
  447. // add to total
  448. cfData.dwTotalSize = GetSizeFromInfString (szFileInfo);
  449. // keep adding to file and dir counters
  450. nCopyResult = (int)DialogBoxParam (
  451. (HANDLE)GetWindowLongPtr(GetParent(hwndDlg), GWLP_HINSTANCE),
  452. MAKEINTRESOURCE(NCDU_COPYING_FILES_DLG),
  453. hwndDlg,
  454. CopyFileDlgProc,
  455. (LPARAM)&cfData);
  456. } // end if source is really a dir
  457. } // end for each dir in list loop
  458. if (nCopyResult == IDOK) {
  459. szDisplayString = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  460. if (szDisplayString == NULL) {
  461. // unable to allocate string buffer so try default message
  462. DisplayMessageBox (
  463. hwndDlg,
  464. NCDU_COPY_COMPLETE,
  465. 0,
  466. MB_OK_TASK_INFO);
  467. } else {
  468. _stprintf (szDisplayString,
  469. GetStringResource (FMT_COPY_COMPLETE_STATS),
  470. cfData.dwDirsCreated, cfData.dwFilesCopied);
  471. MessageBox (
  472. hwndDlg, szDisplayString,
  473. GetStringResource (SZ_APP_TITLE),
  474. MB_OK_TASK_INFO);
  475. FREE_IF_ALLOC (szDisplayString);
  476. }
  477. }
  478. } else {
  479. nCopyResult = IDCANCEL;
  480. }
  481. FREE_IF_ALLOC(szSourceDir);
  482. FREE_IF_ALLOC(szDestDir);
  483. FREE_IF_ALLOC(szFileInfo);
  484. FREE_IF_ALLOC(szClientName);
  485. FREE_IF_ALLOC(szInfName);
  486. FREE_IF_ALLOC(mszDirList);
  487. return (nCopyResult == IDOK ? TRUE : FALSE);
  488. }
  489. static
  490. BOOL
  491. ShareNetSwDlg_WM_INITDIALOG (
  492. IN HWND hwndDlg,
  493. IN WPARAM wParam,
  494. IN LPARAM lParam
  495. )
  496. /*++
  497. Routine Description:
  498. Processes the WM_INITDIALOG windows message. Loads the controls
  499. with the values from the application data structure and
  500. initializes the display mode (i.e. the dlg box size)
  501. Arguments:
  502. IN HWND hwndDlg
  503. Handle to the dialog box window
  504. IN WPARAM wParam
  505. Not Used
  506. IN LPARAM lParam
  507. Not Used
  508. Return Value:
  509. FALSE
  510. --*/
  511. {
  512. LPTSTR szDlgDistPath;
  513. DWORD dwShareType;
  514. RemoveMaximizeFromSysMenu (hwndDlg);
  515. PositionWindow (hwndDlg);
  516. szDlgDistPath = GlobalAlloc(GPTR, MAX_PATH_BYTES);
  517. if (szDlgDistPath == NULL) {
  518. EndDialog (hwndDlg, IDCANCEL);
  519. return FALSE;
  520. }
  521. //
  522. // Determine next message for EndDialog Return based on
  523. // installation to perform
  524. //
  525. if (pAppInfo->itInstall == FloppyDiskInstall) {
  526. nNextDialog = NCDU_SHOW_CREATE_DISKS_DLG;
  527. } else if (pAppInfo->itInstall == OverTheNetInstall) {
  528. nNextDialog = NCDU_SHOW_TARGET_WS_DLG;
  529. } else if (pAppInfo->itInstall == CopyNetAdminUtils) {
  530. nNextDialog = NCDU_SHOW_COPY_ADMIN_UTILS;
  531. }
  532. // get source path for client files
  533. if (*pAppInfo->szDistShowPath == 0) {
  534. // load default values if an existing source dir doesn't exist
  535. GetDistributionPath (hwndDlg, FDT_CLIENT_TREE,
  536. szDlgDistPath, MAX_PATH, &dwShareType);
  537. //then initialize with a default value
  538. lstrcpy (pAppInfo->szDistShowPath, szDlgDistPath);
  539. } else {
  540. if (ValidSharePath(pAppInfo->szDistShowPath) == 0) {
  541. // a valid path is already loaded
  542. if (IsUncPath(pAppInfo->szDistShowPath)) {
  543. dwShareType = NCDU_LOCAL_SHARE_PATH;
  544. } else {
  545. dwShareType = NCDU_HARD_DRIVE_PATH;
  546. }
  547. } else {
  548. // lookup a default path to use
  549. GetDistributionPath (hwndDlg, FDT_CLIENT_TREE,
  550. szDlgDistPath, MAX_PATH, &dwShareType);
  551. //then initialize with a default value
  552. lstrcpy (pAppInfo->szDistShowPath, szDlgDistPath);
  553. }
  554. }
  555. // load fields using data from data structure
  556. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, pAppInfo->szDistShowPath);
  557. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, pAppInfo->szDestPath);
  558. // set edit box text limits
  559. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  560. EM_LIMITTEXT, (WPARAM)(MAX_PATH-1), (LPARAM)0);
  561. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  562. EM_LIMITTEXT, (WPARAM)(MAX_PATH-1), (LPARAM)0);
  563. SendDlgItemMessage (hwndDlg, NCDU_SERVER_NAME,
  564. EM_LIMITTEXT, (WPARAM)(MAX_COMPUTERNAME_LENGTH), (LPARAM)0);
  565. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1,
  566. EM_LIMITTEXT, (WPARAM)(MAX_SHARENAME-1), (LPARAM)0);
  567. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_2,
  568. EM_LIMITTEXT, (WPARAM)(MAX_SHARENAME-1), (LPARAM)0);
  569. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_3,
  570. EM_LIMITTEXT, (WPARAM)(MAX_SHARENAME-1), (LPARAM)0);
  571. // initialize field variables
  572. lstrcpy (szShareName1, GetDefaultShareName(NULL));
  573. lstrcpy (szShareName2, GetDefaultShareName(NULL));
  574. lstrcpy (szDestPath, GetDefaultDestPath());
  575. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, szShareName1);
  576. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, szDestPath);
  577. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2, szShareName2);
  578. // set dialog state to appropriate value
  579. bShareNotCopy = (dwShareType == NCDU_CDROM_PATH ? FALSE : TRUE);
  580. if (pAppInfo->bUseExistingPath) {
  581. CheckRadioButton (hwndDlg,
  582. NCDU_USE_DIST_PATH,
  583. NCDU_FILES_ALREADY_SHARED,
  584. NCDU_USE_DIST_PATH);
  585. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  586. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  587. SetFocus (GetDlgItem(hwndDlg, NCDU_DISTRIBUTION_PATH));
  588. } else {
  589. switch (dwShareType) {
  590. case NCDU_NO_CLIENT_PATH_FOUND:
  591. // no path found
  592. CheckRadioButton (hwndDlg,
  593. NCDU_USE_DIST_PATH,
  594. NCDU_FILES_ALREADY_SHARED,
  595. NCDU_USE_EXISTING_SHARE);
  596. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  597. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  598. SetFocus (GetDlgItem(hwndDlg, NCDU_DISTRIBUTION_PATH));
  599. break;
  600. case NCDU_HARD_DRIVE_PATH:
  601. // path found on hard drive so default is to share
  602. CheckRadioButton (hwndDlg,
  603. NCDU_USE_DIST_PATH,
  604. NCDU_FILES_ALREADY_SHARED,
  605. NCDU_USE_EXISTING_SHARE);
  606. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1,
  607. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  608. SetFocus (GetDlgItem(hwndDlg, NCDU_SHARE_NAME_1));
  609. break;
  610. case NCDU_CDROM_PATH:
  611. // path found on CD-ROM so default is to copy & share
  612. CheckRadioButton (hwndDlg,
  613. NCDU_USE_DIST_PATH,
  614. NCDU_FILES_ALREADY_SHARED,
  615. NCDU_COPY_AND_MAKE_SHARE);
  616. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  617. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  618. SetFocus (GetDlgItem(hwndDlg, NCDU_DESTINATION_PATH));
  619. break;
  620. case NCDU_PATH_FROM_REGISTRY:
  621. case NCDU_LOCAL_SHARE_PATH:
  622. // path already shared
  623. CheckRadioButton (hwndDlg,
  624. NCDU_USE_DIST_PATH,
  625. NCDU_FILES_ALREADY_SHARED,
  626. NCDU_FILES_ALREADY_SHARED);
  627. if (GetServerFromUnc (pAppInfo->szDistShowPath, szDlgDistPath)) {
  628. _tcsupr(szDlgDistPath);
  629. lstrcpy (szServerName, szDlgDistPath);
  630. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME, szDlgDistPath);
  631. if (GetShareFromUnc (pAppInfo->szDistShowPath, szDlgDistPath)) {
  632. lstrcpy (szShareName3, szDlgDistPath);
  633. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3, szDlgDistPath);
  634. } else {
  635. // unable to look up share point so go back to dist path
  636. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, cszEmptyString);
  637. CheckRadioButton (hwndDlg,
  638. NCDU_USE_DIST_PATH,
  639. NCDU_FILES_ALREADY_SHARED,
  640. NCDU_USE_EXISTING_SHARE);
  641. }
  642. } else {
  643. // unable to look up server, so go back to dist path
  644. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME, cszEmptyString);
  645. CheckRadioButton (hwndDlg,
  646. NCDU_USE_DIST_PATH,
  647. NCDU_FILES_ALREADY_SHARED,
  648. NCDU_USE_EXISTING_SHARE);
  649. }
  650. SetFocus (GetDlgItem (hwndDlg, IDOK));
  651. break;
  652. }
  653. }
  654. UpdateDiskSpace(hwndDlg);
  655. UpdateDialogMode (hwndDlg);
  656. PostMessage (GetParent(hwndDlg), NCDU_CLEAR_DLG, (WPARAM)hwndDlg, IDOK);
  657. PostMessage (GetParent(hwndDlg), NCDU_REGISTER_DLG,
  658. NCDU_SHARE_NET_SW_DLG, (LPARAM)hwndDlg);
  659. SetCursor(LoadCursor(NULL, IDC_ARROW));
  660. FREE_IF_ALLOC (szDlgDistPath);
  661. return FALSE;
  662. }
  663. static
  664. BOOL
  665. ShareNetSwDlg_NCDU_SHARE_DIR (
  666. IN HWND hwndDlg,
  667. IN WPARAM wParam, // not used
  668. IN LPARAM lParam // pointer to SPS_DATA block
  669. )
  670. /*++
  671. Routine Description:
  672. Shares the Distribution dir path.
  673. Uses the share name entered in the display. If
  674. successful this message terminates the dialog box, otherwise
  675. an error message will be displayed.
  676. Arguments:
  677. IN HWND hwndDlg
  678. Handle to dialog box window
  679. IN WPARAM wParam
  680. Not Used
  681. IN LPARAM lParam
  682. pointer to SPS_DATA block
  683. Return Value:
  684. TRUE if shared
  685. FALSE if not (GetLastError for info)
  686. --*/
  687. {
  688. PSPS_DATA pspData;
  689. LPWSTR szTempMachineName = NULL;
  690. int nDlgBoxStatus;
  691. pspData = (PSPS_DATA)lParam;
  692. if (*pspData->szServer != cBackslash) {
  693. szTempMachineName = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  694. if (szTempMachineName != NULL) {
  695. lstrcpy (szTempMachineName, cszDoubleBackslash);
  696. lstrcat (szTempMachineName, pspData->szServer);
  697. pspData->szServer = szTempMachineName;
  698. }
  699. }
  700. nDlgBoxStatus = (int)DialogBoxParam (
  701. (HINSTANCE)GetWindowLongPtr(hwndDlg, GWLP_HINSTANCE),
  702. MAKEINTRESOURCE (NCDU_DLG_SHARING_PATH),
  703. hwndDlg,
  704. SharePathDlgProc,
  705. lParam);
  706. FREE_IF_ALLOC (szTempMachineName);
  707. return (nDlgBoxStatus == IDOK ? TRUE : FALSE);
  708. }
  709. static
  710. BOOL
  711. ShareNetSwDlg_IDOK (
  712. IN HWND hwndDlg,
  713. IN WPARAM wParam,
  714. IN LPARAM lParam
  715. )
  716. /*++
  717. Routine Description:
  718. Processes the IDOK button depending on the mode selected. If the
  719. copy files mode is selected, then the source, destination and
  720. clients are validated and the files are copied. If the share
  721. distribution mode is selected, then the directory path is
  722. shared on the local machine.
  723. The validation consists of the following:
  724. FILES_ALREADY_SHARED: (bottom button)
  725. Get Server Name
  726. must be non blank
  727. must be name of machine on network
  728. Get Sharepoint Name
  729. must be non-blank
  730. must exist on above server
  731. signal if > DOS compatible name length
  732. \\server\share must be a valid client directory tree
  733. Use the distribution path: (any of the top buttons)
  734. Check Destination path
  735. must be non-blank
  736. must be a valid client distribution directory tree
  737. SHARE DISTRIBUTION_PATH:
  738. Get share name
  739. must be non-blank
  740. must not be in use
  741. signal if > DOS compatible name length
  742. Signal if name is in currently in use
  743. user may either use current name or change
  744. COPY AND SHARE:
  745. Get Destination Path
  746. must be non-blank
  747. Get share name
  748. must be non-blank
  749. must not be in use
  750. signal if > DOS compatible name length
  751. Signal if name is in currently in use
  752. Check disk space on destination machine
  753. Copy files from distribution to destination dir's
  754. If copy went OK, then update dlg fields and share
  755. USE EXISTING PATH:
  756. no sharing or validation:
  757. Arguments:
  758. IN HWND hwndDlg
  759. Return Value:
  760. TRUE if the message is processed by this routine
  761. FALSE if not
  762. --*/
  763. {
  764. LPTSTR szDlgDistPath;
  765. LPTSTR szDlgDestPath;
  766. LPTSTR szPathBuff;
  767. LPTSTR szMsgBuff;
  768. LPTSTR szSharePath;
  769. TCHAR szDlgShareName[MAX_SHARENAME];
  770. TCHAR szServerName[MAX_COMPUTERNAME_LENGTH+1];
  771. UINT nDirMsg;
  772. BOOL bShareDest;
  773. DWORD dwBytesToCopy;
  774. DWORD dwBufLen;
  775. DWORD dwShareType;
  776. SPS_DATA spData;
  777. LPTSTR szShareName;
  778. int nMbResult;
  779. BOOL bFinishOff = FALSE;
  780. switch (HIWORD(wParam)) {
  781. case BN_CLICKED:
  782. szDlgDistPath = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  783. szDlgDestPath = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  784. szPathBuff = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  785. szMsgBuff = GlobalAlloc (GPTR, SMALL_BUFFER_SIZE * sizeof(TCHAR));
  786. szSharePath = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  787. if ((szDlgDistPath != NULL) &&
  788. (szDlgDestPath != NULL) &&
  789. (szMsgBuff != NULL) &&
  790. (szSharePath != NULL) &&
  791. (szPathBuff != NULL)) {
  792. if (IsDlgButtonChecked(hwndDlg, NCDU_FILES_ALREADY_SHARED) == CHECKED) {
  793. // use server & share found in the group box
  794. // make UNC from server & share found in dialog box
  795. lstrcpy (szDlgDistPath, cszDoubleBackslash);
  796. GetDlgItemText (hwndDlg, NCDU_SERVER_NAME,
  797. &szDlgDistPath[2], MAX_COMPUTERNAME_LENGTH+1);
  798. TrimSpaces (&szDlgDistPath[2]);
  799. if (lstrlen (&szDlgDistPath[2]) == 0) {
  800. DisplayMessageBox (
  801. hwndDlg,
  802. NCDU_NO_SERVER,
  803. 0,
  804. MB_OK_TASK_EXCL);
  805. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME,
  806. &szDlgDistPath[2]);
  807. SetFocus (GetDlgItem (hwndDlg, NCDU_SERVER_NAME));
  808. SendDlgItemMessage (hwndDlg, NCDU_SERVER_NAME,
  809. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  810. goto IDOK_ExitClicked;
  811. }
  812. if (ComputerPresent (szDlgDistPath)) {
  813. lstrcat (szDlgDistPath, cszBackslash);
  814. szShareName = &szDlgDistPath[lstrlen(szDlgDistPath)];
  815. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3,
  816. szShareName, MAX_SHARENAME+1);
  817. TrimSpaces(szShareName);
  818. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3,
  819. szShareName);
  820. if (lstrlen(szShareName) > LM20_DEVLEN) {
  821. nMbResult = DisplayMessageBox (
  822. hwndDlg,
  823. NCDU_NOT_DOS_SHARE,
  824. 0,
  825. MB_OKCANCEL_TASK_EXCL_DEF2);
  826. if (nMbResult == IDCANCEL) {
  827. // they pressed cancel, so go back to the offending share and
  828. // try again
  829. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_3));
  830. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_3,
  831. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  832. goto IDOK_ExitClicked;
  833. }
  834. // if here the user want's to keep the share name so continue
  835. }
  836. if (lstrlen(szShareName) == 0) {
  837. DisplayMessageBox (
  838. hwndDlg,
  839. NCDU_NO_SHARE_NAME,
  840. 0,
  841. MB_OK_TASK_EXCL);
  842. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_3));
  843. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_3,
  844. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  845. goto IDOK_ExitClicked;
  846. }
  847. if (szDlgDistPath[lstrlen(szDlgDistPath)-1] != cBackslash)
  848. lstrcat (szDlgDistPath, cszBackslash);
  849. dwShareType = ValidSharePath (szDlgDistPath);
  850. if (dwShareType == 0) {
  851. // valid, so copy to dist path and exit
  852. lstrcpy (pAppInfo->szDistShowPath, szDlgDistPath);
  853. lstrcpy (pAppInfo->szDistPath, szDlgDistPath);
  854. bFinishOff = TRUE;
  855. } else {
  856. // unable to locate sharepoint
  857. DisplayMessageBox (
  858. hwndDlg,
  859. dwShareType,
  860. 0,
  861. MB_OK_TASK_EXCL);
  862. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_3));
  863. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_3,
  864. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  865. }
  866. } else {
  867. // unable to locate server
  868. DisplayMessageBox (
  869. hwndDlg,
  870. NCDU_SERVER_NOT_PRESENT,
  871. 0,
  872. MB_OK_TASK_EXCL);
  873. SetFocus (GetDlgItem (hwndDlg, NCDU_SERVER_NAME));
  874. SendDlgItemMessage (hwndDlg, NCDU_SERVER_NAME,
  875. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  876. }
  877. } else {
  878. // they want to use the path in the edit box so
  879. // validate distribution directory path
  880. GetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, szDlgDistPath, MAX_PATH);
  881. TrimSpaces (szDlgDistPath);
  882. if (lstrlen(szDlgDistPath) == 0) {
  883. // no source path
  884. DisplayMessageBox (
  885. hwndDlg,
  886. NCDU_PATH_CANNOT_BE_BLANK,
  887. 0,
  888. MB_OK_TASK_EXCL);
  889. // set focus and leave so the user can correct
  890. SetFocus (GetDlgItem (hwndDlg, NCDU_DISTRIBUTION_PATH));
  891. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  892. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  893. goto IDOK_ExitClicked;
  894. }
  895. if ((nDirMsg = ValidSharePath(szDlgDistPath)) != 0) {
  896. // error in Distribution path
  897. DisplayMessageBox (
  898. hwndDlg,
  899. nDirMsg,
  900. 0,
  901. MB_OK_TASK_EXCL);
  902. #ifdef TERMSRV
  903. szCommandLineVal[0] = 0x00;
  904. #endif // TERMSRV
  905. // error in directory path so set focus to directory entry
  906. SetFocus (GetDlgItem(hwndDlg, NCDU_DISTRIBUTION_PATH));
  907. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  908. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  909. goto IDOK_ExitClicked;
  910. }
  911. // distribution path is valid so save the path
  912. // and the server and then continue
  913. lstrcpy (pAppInfo->szDistShowPath, szDlgDistPath);
  914. if (IsDlgButtonChecked(hwndDlg, NCDU_USE_EXISTING_SHARE) == CHECKED) {
  915. GetNetPathInfo (pAppInfo->szDistShowPath, szServerName,
  916. szSharePath);
  917. if ((*szServerName == 0) || (*szSharePath == 0)) {
  918. // unable to get path information
  919. DisplayMessageBox (
  920. hwndDlg,
  921. NCDU_UNABLE_GET_PATH_INFO,
  922. 0,
  923. MB_OK_TASK_EXCL);
  924. SetFocus (GetDlgItem(hwndDlg, NCDU_DISTRIBUTION_PATH));
  925. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  926. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  927. goto IDOK_ExitClicked;
  928. }
  929. // share the path in the source name edit control
  930. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, szDlgShareName, MAX_SHARENAME);
  931. TrimSpaces (szDlgShareName);
  932. // update edit field in case we need to come back
  933. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, szDlgShareName);
  934. if (lstrlen(szDlgShareName) > LM20_DEVLEN) {
  935. nMbResult = DisplayMessageBox (
  936. hwndDlg,
  937. NCDU_NOT_DOS_SHARE,
  938. 0,
  939. MB_OKCANCEL_TASK_EXCL_DEF2);
  940. if (nMbResult == IDCANCEL) {
  941. // they pressed cancel, so go back to the offending share and
  942. // try again
  943. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1));
  944. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1,
  945. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  946. goto IDOK_ExitClicked;
  947. }
  948. // if here the user want's to keep the share name so continue
  949. } else if (lstrlen(szDlgShareName) == 0) {
  950. // no share name specified so display error and
  951. // exit
  952. DisplayMessageBox (
  953. hwndDlg,
  954. NCDU_NO_SHARE_NAME,
  955. 0,
  956. MB_OK_TASK_EXCL);
  957. SetFocus (GetDlgItem(hwndDlg,
  958. NCDU_SHARE_NAME_1));
  959. SendDlgItemMessage (hwndDlg,
  960. NCDU_SHARE_NAME_1,
  961. EM_SETSEL, (WPARAM)0,
  962. (LPARAM)-1);
  963. goto IDOK_ExitClicked;
  964. }
  965. // there is a share name so try to share the source
  966. // dir. if it's not a UNC since they are by
  967. // definition shared
  968. if (IsShareNameUsed (szServerName, szDlgShareName,
  969. &dwShareType, szPathBuff)) {
  970. if (dwShareType == NCDU_SHARE_IS_CLIENT_TREE) {
  971. // then this is the name of a shared client
  972. // dir tree already, so tell the user about it
  973. _stprintf (szMsgBuff,
  974. GetStringResource (FMT_SHARE_IS_CLIENT_TREE),
  975. szDlgShareName, szServerName, szPathBuff);
  976. if (MessageBox (hwndDlg, szMsgBuff,
  977. GetStringResource (SZ_APP_TITLE),
  978. MB_OKCANCEL_TASK_EXCL_DEF2) == IDOK) {
  979. // use the existing path and share name
  980. lstrcpy (pAppInfo->szDistShowPath, cszDoubleBackslash);
  981. lstrcat (pAppInfo->szDistShowPath, szServerName);
  982. lstrcat (pAppInfo->szDistShowPath, cszBackslash);
  983. lstrcat (pAppInfo->szDistShowPath, szDlgShareName);
  984. lstrcat (pAppInfo->szDistShowPath, cszBackslash);
  985. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, pAppInfo->szDistShowPath);
  986. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, cszEmptyString);
  987. // that's it then, so exit
  988. lstrcpy (pAppInfo->szDistPath, pAppInfo->szDistShowPath);
  989. bFinishOff = TRUE;
  990. } else {
  991. // they want to try again
  992. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1));
  993. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1,
  994. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  995. goto IDOK_ExitClicked;
  996. }
  997. } else {
  998. // this is the name of some other shared
  999. // directory so tell the user
  1000. _stprintf (szMsgBuff,
  1001. GetStringResource (FMT_SHARE_IS_ALREADY_USED),
  1002. szDlgShareName, szServerName, szPathBuff);
  1003. MessageBox (hwndDlg, szMsgBuff,
  1004. GetStringResource (SZ_APP_TITLE),
  1005. MB_OK_TASK_EXCL);
  1006. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1));
  1007. SendDlgItemMessage (hwndDlg,
  1008. NCDU_SHARE_NAME_1,
  1009. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1010. goto IDOK_ExitClicked;
  1011. }
  1012. } else {
  1013. // share name isn't in use, so go ahead and share it
  1014. // try to share
  1015. lstrcpy (szMsgBuff, GetStringResource (FMT_SHARE_REMARK));
  1016. spData.szServer = szServerName;
  1017. spData.szPath = szSharePath;
  1018. spData.szShareName = szDlgShareName;
  1019. spData.szRemark = szMsgBuff;
  1020. if (ShareNetSwDlg_NCDU_SHARE_DIR (hwndDlg,
  1021. (WPARAM)0, (LPARAM)&spData)) {
  1022. // shared successfully so
  1023. // make new UNC for distribution path
  1024. // then exit
  1025. lstrcpy (pAppInfo->szDistShowPath, cszDoubleBackslash);
  1026. lstrcat (pAppInfo->szDistShowPath, szServerName);
  1027. lstrcat (pAppInfo->szDistShowPath, cszBackslash);
  1028. lstrcat (pAppInfo->szDistShowPath, szDlgShareName);
  1029. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1030. pAppInfo->szDistShowPath);
  1031. lstrcpy (pAppInfo->szDistPath, pAppInfo->szDistShowPath);
  1032. bFinishOff = TRUE;
  1033. } else {
  1034. // unable to share dir, error has been
  1035. // signaled via message box already
  1036. SetFocus (GetDlgItem(hwndDlg,
  1037. NCDU_SHARE_NAME_1));
  1038. SendDlgItemMessage (hwndDlg,
  1039. NCDU_SHARE_NAME_1,
  1040. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1041. }
  1042. } // end if sharename has some text
  1043. } else if (IsDlgButtonChecked(hwndDlg, NCDU_COPY_AND_MAKE_SHARE) == CHECKED) {
  1044. // copy the files from the distribution path to the destination
  1045. // path then share the destination path
  1046. // check destination string
  1047. GetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, szDlgDestPath, MAX_PATH);
  1048. TrimSpaces (szDlgDestPath);
  1049. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, szDlgDestPath);
  1050. if (lstrlen(szDlgDestPath) == 0) {
  1051. // destination path is empty so go back and try again
  1052. // no source path
  1053. DisplayMessageBox (
  1054. hwndDlg,
  1055. NCDU_PATH_CANNOT_BE_BLANK,
  1056. 0,
  1057. MB_OK_TASK_EXCL);
  1058. // set focus and leave so the user can correct
  1059. SetFocus (GetDlgItem (hwndDlg, NCDU_DESTINATION_PATH));
  1060. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  1061. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1062. goto IDOK_ExitClicked;
  1063. } else {
  1064. // there's a string in the destination so
  1065. // trim and copy to global struct
  1066. lstrcpy (pAppInfo->szDestPath, szDlgDestPath);
  1067. // see if there's a share name
  1068. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2,
  1069. szDlgShareName, MAX_SHARENAME);
  1070. TrimSpaces (szDlgShareName);
  1071. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2,
  1072. szDlgShareName);
  1073. if (lstrlen(szDlgShareName) > LM20_DEVLEN) {
  1074. nMbResult = DisplayMessageBox (
  1075. hwndDlg,
  1076. NCDU_NOT_DOS_SHARE,
  1077. 0,
  1078. MB_OKCANCEL_TASK_EXCL_DEF2);
  1079. if (nMbResult == IDCANCEL) {
  1080. // they pressed cancel, so go back to the offending share and
  1081. // try again
  1082. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_2));
  1083. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_2,
  1084. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1085. goto IDOK_ExitClicked;
  1086. }
  1087. // if here the user want's to keep the share name so continue
  1088. }
  1089. if (lstrlen(szDlgShareName) == 0) {
  1090. // no share name so display error and
  1091. // bail out
  1092. DisplayMessageBox (
  1093. hwndDlg,
  1094. NCDU_NO_SHARE_NAME,
  1095. 0,
  1096. MB_OK_TASK_EXCL);
  1097. SetFocus (GetDlgItem(hwndDlg,
  1098. NCDU_SHARE_NAME_2));
  1099. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_2,
  1100. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1101. goto IDOK_ExitClicked;
  1102. } else {
  1103. GetNetPathInfo (pAppInfo->szDestPath,
  1104. szServerName,
  1105. szSharePath);
  1106. if ((*szServerName == 0) || (*szSharePath == 0)) {
  1107. // unable to get path information
  1108. DisplayMessageBox (
  1109. hwndDlg,
  1110. NCDU_UNABLE_GET_PATH_INFO,
  1111. 0,
  1112. MB_OK_TASK_EXCL);
  1113. SetFocus (GetDlgItem (hwndDlg, NCDU_DESTINATION_PATH));
  1114. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  1115. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1116. goto IDOK_ExitClicked;
  1117. }
  1118. if (IsShareNameUsed (szServerName, szDlgShareName,
  1119. &dwShareType, szPathBuff)) {
  1120. // this is the name of some other shared
  1121. // directory so tell the user
  1122. _stprintf (szMsgBuff,
  1123. GetStringResource (FMT_SHARE_IS_ALREADY_USED),
  1124. szDlgShareName, szServerName, szPathBuff);
  1125. MessageBox (hwndDlg, szMsgBuff,
  1126. GetStringResource (SZ_APP_TITLE),
  1127. MB_OK_TASK_EXCL);
  1128. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_2));
  1129. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_2,
  1130. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1131. goto IDOK_ExitClicked;
  1132. } else {
  1133. // indicate that the destination dir
  1134. // should be shared after the files have been
  1135. // copied.
  1136. bShareDest = TRUE;
  1137. }
  1138. }
  1139. // so at this point there's a destination dir and
  1140. // a share name if one's needed. finally we need to
  1141. // see if any client's have been selected to be
  1142. // copied.
  1143. dwBytesToCopy = UpdateDiskSpace(hwndDlg);
  1144. if (dwBytesToCopy == 0) {
  1145. DisplayMessageBox (
  1146. hwndDlg,
  1147. NCDU_NO_CLIENTS_SELECTED,
  1148. 0,
  1149. MB_OK_TASK_EXCL);
  1150. SetFocus (GetDlgItem(hwndDlg, NCDU_DISTRIBUTION_PATH));
  1151. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1152. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1153. goto IDOK_ExitClicked;
  1154. }
  1155. // there's clients selected, now see if they'll fit
  1156. if (ComputeFreeSpace(pAppInfo->szDestPath) < dwBytesToCopy) {
  1157. DisplayMessageBox (
  1158. hwndDlg,
  1159. NCDU_INSUFFICIENT_DISK_SPACE,
  1160. 0,
  1161. MB_OK_TASK_EXCL);
  1162. SetFocus (GetDlgItem(hwndDlg, NCDU_DESTINATION_PATH));
  1163. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  1164. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1165. goto IDOK_ExitClicked;
  1166. }
  1167. // so there should be enough free space
  1168. if (CopyFilesFromDistToDest (hwndDlg)) {
  1169. // copy was successful so
  1170. // copy destination name to distribution name
  1171. lstrcpy (pAppInfo->szDistShowPath,
  1172. pAppInfo->szDestPath);
  1173. *pAppInfo->szDestPath = 0;
  1174. // update dialog box fields
  1175. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1176. pAppInfo->szDistShowPath);
  1177. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH,
  1178. pAppInfo->szDestPath);
  1179. // since the files have been successfully copied and
  1180. // and the paths have been transposed (i.e. dest is now
  1181. // dist) update the button state so that if a sharing
  1182. // error occurs, the files won't have to be copied again
  1183. CheckRadioButton (hwndDlg,
  1184. NCDU_USE_DIST_PATH,
  1185. NCDU_FILES_ALREADY_SHARED,
  1186. NCDU_USE_EXISTING_SHARE);
  1187. bShareNotCopy = TRUE;
  1188. UpdateDialogMode (hwndDlg);
  1189. //
  1190. // then share the destination dir (which is now
  1191. // in the distribution path)
  1192. if (bShareDest) {
  1193. lstrcpy (szMsgBuff, GetStringResource (FMT_SHARE_REMARK));
  1194. spData.szServer = szServerName; // local machine
  1195. spData.szPath = szSharePath;
  1196. spData.szShareName = szDlgShareName;
  1197. spData.szRemark = szMsgBuff;
  1198. if (ShareNetSwDlg_NCDU_SHARE_DIR (hwndDlg,
  1199. (WPARAM)0, (LPARAM)&spData)) {
  1200. // shared successfully so
  1201. // make new UNC for distribution path
  1202. // then exit
  1203. lstrcpy (pAppInfo->szDistShowPath, cszDoubleBackslash);
  1204. lstrcat (pAppInfo->szDistShowPath, szServerName);
  1205. lstrcat (pAppInfo->szDistShowPath, cszBackslash);
  1206. lstrcat (pAppInfo->szDistShowPath, szDlgShareName);
  1207. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1208. pAppInfo->szDistShowPath);
  1209. lstrcpy (pAppInfo->szDistPath, pAppInfo->szDistShowPath);
  1210. bFinishOff = TRUE;
  1211. } else {
  1212. // the share operation failed, but was
  1213. // already signaled.
  1214. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1));
  1215. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1,
  1216. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1217. }
  1218. } else {
  1219. // just leave
  1220. lstrcpy (pAppInfo->szDistPath, pAppInfo->szDistShowPath);
  1221. bFinishOff = TRUE;
  1222. }
  1223. } else {
  1224. // copy was not successful, but error has
  1225. // already been signaled to the user
  1226. SetFocus (GetDlgItem (hwndDlg, NCDU_DESTINATION_PATH));
  1227. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  1228. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1229. }
  1230. } // end if there's a destination directory entry
  1231. } else { // end if copy and share is checked
  1232. // they must want to use an existing path
  1233. // if this is for the Make Over The Net boot disk
  1234. // then this must be a shared path
  1235. //
  1236. // at this point we can assume the path is VALID and a
  1237. // distribution tree. Now see if it's visible over
  1238. // the network if it's needed for an OTN install disk
  1239. if (pAppInfo->itInstall == OverTheNetInstall) {
  1240. if (IsUncPath (pAppInfo->szDistShowPath)) {
  1241. // if it's UNC and VALID then it must be shared so
  1242. // just copy from display to use path
  1243. lstrcpy (pAppInfo->szDistPath,
  1244. pAppInfo->szDistShowPath);
  1245. bFinishOff = TRUE;
  1246. } else {
  1247. // not a UNC, so see if the path is shared
  1248. if (OnRemoteDrive(pAppInfo->szDistShowPath)) {
  1249. // If it's on a remote drive, then it
  1250. // must be shared some where
  1251. // make into a UNC before leaving
  1252. lstrcpy (szDlgDistPath, pAppInfo->szDistShowPath);
  1253. dwBufLen = MAX_PATH_BYTES;
  1254. LookupRemotePath (szDlgDistPath, pAppInfo->szDistPath, &dwBufLen);
  1255. bFinishOff = TRUE;
  1256. } else {
  1257. // it's not a remote drive so see if it's shared
  1258. // locally.
  1259. dwBufLen = MAX_PATH_BYTES;
  1260. if (LookupLocalShare(pAppInfo->szDistShowPath, TRUE, szDlgDistPath, &dwBufLen)) {
  1261. lstrcpy (pAppInfo->szDistPath, szDlgDistPath);
  1262. bFinishOff = TRUE;
  1263. } else {
  1264. // it's not shared on this or any other
  1265. // machine so there's no point in continuing
  1266. // with an OTN install disk.
  1267. DisplayMessageBox (
  1268. hwndDlg,
  1269. NCDU_EXIT_SHARE_PATH,
  1270. 0,
  1271. MB_OK_TASK_EXCL);
  1272. bFinishOff = FALSE;
  1273. } // endif look up local share
  1274. } // end if lookup remote drive
  1275. } // end if UNC path name
  1276. } else {
  1277. // there's no reason to require the path be
  1278. // shared just to make some floppy disks so
  1279. // continue
  1280. lstrcpy (pAppInfo->szDistPath, pAppInfo->szDistShowPath);
  1281. bFinishOff = TRUE;
  1282. } // end if OTN install
  1283. } // endif Use Exisiting Path
  1284. }// end if files not already shared
  1285. } // end if memory allocation was successful
  1286. IDOK_ExitClicked:
  1287. FREE_IF_ALLOC(szDlgDistPath);
  1288. FREE_IF_ALLOC(szDlgDestPath);
  1289. FREE_IF_ALLOC(szMsgBuff);
  1290. FREE_IF_ALLOC(szPathBuff);
  1291. FREE_IF_ALLOC(szSharePath);
  1292. if (bFinishOff){
  1293. PostMessage (hwndDlg, NCDU_VALIDATE_AND_END,
  1294. (WPARAM)FALSE, (LPARAM)0);
  1295. } else {
  1296. SetCursor(LoadCursor(NULL, IDC_ARROW));
  1297. }
  1298. return TRUE;
  1299. default:
  1300. return FALSE;
  1301. }
  1302. }
  1303. static
  1304. BOOL
  1305. ShareNetSwDlg_WM_COMMAND (
  1306. IN HWND hwndDlg,
  1307. IN WPARAM wParam,
  1308. IN LPARAM lParam
  1309. )
  1310. /*++
  1311. Routine Description:
  1312. Processes the WM_COMMAND windows message in response to user input.
  1313. Dispatches to the appropriate routine based on the control that
  1314. was selected.
  1315. Arguments:
  1316. IN HWND hwndDlg
  1317. Handle to dialog box window
  1318. IN WPARAM wParam
  1319. LOWORD has id of control sending the message
  1320. HIWORD has the notification code (if applicable)
  1321. IN LPARAM lParam
  1322. Not Used
  1323. Return Value:
  1324. TRUE if message not processed by this routine, otherwise the value
  1325. returned by the dispatched routine
  1326. --*/
  1327. {
  1328. switch (LOWORD(wParam)) {
  1329. case IDOK: return ShareNetSwDlg_IDOK (hwndDlg, wParam, lParam);
  1330. case IDCANCEL:
  1331. switch (HIWORD(wParam)) {
  1332. case BN_CLICKED:
  1333. PostMessage (GetParent(hwndDlg), NCDU_SHOW_SW_CONFIG_DLG, 0, 0);
  1334. SetCursor(LoadCursor(NULL, IDC_WAIT));
  1335. return TRUE;
  1336. default:
  1337. return FALSE;
  1338. }
  1339. case NCDU_BROWSE_DIST:
  1340. switch (HIWORD(wParam)) {
  1341. case BN_CLICKED:
  1342. PostMessage (hwndDlg, NCDU_BROWSE_DIST_PATH, 0, 0);
  1343. SetCursor(LoadCursor(NULL, IDC_WAIT));
  1344. return TRUE;
  1345. default:
  1346. return FALSE;
  1347. }
  1348. case NCDU_USE_DIST_PATH:
  1349. case NCDU_USE_EXISTING_SHARE:
  1350. case NCDU_COPY_AND_MAKE_SHARE:
  1351. case NCDU_FILES_ALREADY_SHARED:
  1352. // these buttons don't send a notification message
  1353. UpdateDiskSpace (hwndDlg);
  1354. UpdateDialogMode (hwndDlg);
  1355. return TRUE;
  1356. case NCDU_DISTRIBUTION_PATH:
  1357. switch (HIWORD(wParam)) {
  1358. case EN_KILLFOCUS:
  1359. UpdateDiskSpace(hwndDlg);
  1360. return TRUE;
  1361. default:
  1362. return FALSE;
  1363. }
  1364. case NCDU_SHARE_NET_SW_DLG_HELP:
  1365. switch (HIWORD(wParam)) {
  1366. case BN_CLICKED:
  1367. // return ShowAppHelp (hwndDlg, LOWORD(wParam));
  1368. return PostMessage (GetParent(hwndDlg), WM_HOTKEY,
  1369. (WPARAM)NCDU_HELP_HOT_KEY, 0);
  1370. default:
  1371. return FALSE;
  1372. }
  1373. default:
  1374. return FALSE;
  1375. }
  1376. }
  1377. static
  1378. BOOL
  1379. ShareNetSwDlg_NCDU_BROWSE_DIST_PATH (
  1380. IN HWND hwndDlg,
  1381. IN WPARAM wParam,
  1382. IN LPARAM lParam
  1383. )
  1384. /*++
  1385. Routine Description:
  1386. Displays the file /dir browser to find distribution path entry
  1387. Arguments:
  1388. IN HWND hwndDlg
  1389. Handle to dialog box window
  1390. IN WPARAM wParam
  1391. Not Used
  1392. IN LPARAM lParam
  1393. Not Used
  1394. Return Value:
  1395. TRUE
  1396. --*/
  1397. {
  1398. DB_DATA BrowseInfo;
  1399. LPTSTR szTempPath;
  1400. szTempPath = GlobalAlloc (GPTR, (MAX_PATH_BYTES + sizeof(TCHAR)));
  1401. if (szTempPath == NULL) return TRUE;
  1402. GetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, szTempPath, MAX_PATH);
  1403. BrowseInfo.dwTitle = NCDU_BROWSE_CLIENT_DIST_PATH;
  1404. BrowseInfo.szPath = szTempPath;
  1405. BrowseInfo.Flags = 0;
  1406. if (DialogBoxParam (
  1407. (HINSTANCE)GetWindowLongPtr(hwndDlg, GWLP_HINSTANCE),
  1408. MAKEINTRESOURCE(NCDU_DIR_BROWSER),
  1409. hwndDlg,
  1410. DirBrowseDlgProc,
  1411. (LPARAM)&BrowseInfo) == IDOK) {
  1412. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, szTempPath);
  1413. }
  1414. SetFocus (GetDlgItem (hwndDlg, NCDU_DISTRIBUTION_PATH));
  1415. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1416. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1417. FREE_IF_ALLOC (szTempPath);
  1418. return TRUE;
  1419. }
  1420. static
  1421. BOOL
  1422. ShareNetSwDlg_NCDU_VALIDATE_AND_END (
  1423. IN HWND hwndDlg,
  1424. IN WPARAM wParam,
  1425. IN LPARAM lParam
  1426. )
  1427. /*++
  1428. Routine Description:
  1429. Performs all validation and field updates before exiting the
  1430. dialog to the nNextDialog. If all validations are successful
  1431. then the EndDialog is called, otherwise the function returns
  1432. to the dialog box after displaying an error message and
  1433. setting the focus to the offending control if necessary.
  1434. Arguments:
  1435. IN HWND hwndDlg
  1436. Handle to dialog box window
  1437. IN WPARAM wParam
  1438. (BOOL) validate dist path (ignored, now since all the validation
  1439. is performed in the _IDOK function.
  1440. IN LPARAM lParam
  1441. Not Used
  1442. Return Value:
  1443. FALSE
  1444. --*/
  1445. {
  1446. BOOL bValidate = FALSE;
  1447. LPTSTR szDlgDistPath;
  1448. LONG lTrysLeft;
  1449. szDlgDistPath = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  1450. if (szDlgDistPath == NULL) return TRUE;
  1451. // copy the app data to the local path for validation
  1452. lstrcpy (szDlgDistPath, pAppInfo->szDistPath);
  1453. bValidate = TRUE;
  1454. // if bValidate is true at this point, pAppInfo->szDistShowPath should
  1455. // contain the UNC version of the original file path. The "signature"
  1456. // file (i.e. the INF) will be appended to the path to determine if
  1457. // this is indeed a valid path.
  1458. if (bValidate) {
  1459. lstrcpy (szDlgDistPath, pAppInfo->szDistPath);
  1460. if (szDlgDistPath[lstrlen(szDlgDistPath)-1] != cBackslash) lstrcat (szDlgDistPath, cszBackslash);
  1461. lstrcat (szDlgDistPath, cszAppInfName);
  1462. lTrysLeft = 50; // wait for 5 seconds
  1463. while (!FileExists(szDlgDistPath)) {
  1464. Sleep (100); // wait for server to establish
  1465. // connection and try again
  1466. if (--lTrysLeft == 0) break;
  1467. }
  1468. if (!FileExists(szDlgDistPath)) {
  1469. // not a valid distribution share so display error message
  1470. DisplayMessageBox (
  1471. hwndDlg,
  1472. NCDU_NOT_DIST_TREE,
  1473. 0,
  1474. MB_OK_TASK_EXCL);
  1475. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1476. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1477. SetFocus (GetDlgItem(hwndDlg, NCDU_DISTRIBUTION_PATH));
  1478. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1479. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1480. } else {
  1481. if (IsUncPath(pAppInfo->szDistPath)) {
  1482. // valid path so extract the server and open the registry on
  1483. // the server
  1484. lstrcpy (szDlgDistPath, cszDoubleBackslash);
  1485. GetServerFromUnc (pAppInfo->szDistPath, &szDlgDistPath[2]);
  1486. if (RegConnectRegistry (szDlgDistPath,
  1487. HKEY_LOCAL_MACHINE, &pAppInfo->hkeyMachine) != ERROR_SUCCESS) {
  1488. // if unable to connect to remote registry, use local registry
  1489. pAppInfo->hkeyMachine = HKEY_LOCAL_MACHINE;
  1490. }
  1491. } else {
  1492. // not a UNC so assume it's on the local machine
  1493. pAppInfo->hkeyMachine = HKEY_LOCAL_MACHINE;
  1494. }
  1495. //
  1496. // save dlg mode
  1497. //
  1498. if (IsDlgButtonChecked(hwndDlg, NCDU_USE_DIST_PATH) == CHECKED) {
  1499. pAppInfo->bUseExistingPath = TRUE;
  1500. } else {
  1501. pAppInfo->bUseExistingPath = FALSE;
  1502. //
  1503. // save the path in the registry for next time
  1504. //
  1505. SavePathToRegistry (pAppInfo->szDistPath,
  1506. cszLastClientServer,
  1507. cszLastClientSharepoint);
  1508. }
  1509. PostMessage (GetParent(hwndDlg), nNextDialog, 0, 0);
  1510. }
  1511. }
  1512. FREE_IF_ALLOC (szDlgDistPath);
  1513. return TRUE;
  1514. }
  1515. INT_PTR CALLBACK
  1516. ShareNetSwDlgProc (
  1517. IN HWND hwndDlg,
  1518. IN UINT message,
  1519. IN WPARAM wParam,
  1520. IN LPARAM lParam
  1521. )
  1522. /*++
  1523. Routine Description:
  1524. Main Dialog message procedure. Dispatches to the appropriate routine
  1525. to process the following windows messages:
  1526. WM_INITDIALOG: Dialog box initialization
  1527. WM_COMMAND: User Input
  1528. NCDU_SHARE_DIR: shares the specified dir to the net
  1529. all other windows messages are handled by the default dialog proc.
  1530. Arguments:
  1531. Standard WNDPROC args
  1532. Return Value:
  1533. FALSE if the message is not processed by this module, otherwise
  1534. the value returned by the dispatched routine.
  1535. --*/
  1536. {
  1537. switch (message) {
  1538. #ifdef TERMSRV
  1539. case WM_INITDIALOG: if ( szCommandLineVal[0] != 0x00 ) {
  1540. ShareNetSwDlg_WM_INITDIALOG (hwndDlg, wParam, lParam);
  1541. CheckRadioButton (hwndDlg,
  1542. NCDU_USE_DIST_PATH,
  1543. NCDU_FILES_ALREADY_SHARED,
  1544. NCDU_USE_DIST_PATH);
  1545. UpdateDialogMode (hwndDlg);
  1546. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, szCommandLineVal);
  1547. ShareNetSwDlg_IDOK (hwndDlg, BN_CLICKED, lParam);
  1548. return FALSE;
  1549. }
  1550. else
  1551. return (ShareNetSwDlg_WM_INITDIALOG (hwndDlg, wParam, lParam));
  1552. #else // TERMSRV
  1553. case WM_INITDIALOG: return (ShareNetSwDlg_WM_INITDIALOG (hwndDlg, wParam, lParam));
  1554. #endif // TERMSRV
  1555. case WM_COMMAND: return (ShareNetSwDlg_WM_COMMAND (hwndDlg, wParam, lParam));
  1556. case NCDU_SHARE_DIR: return (ShareNetSwDlg_NCDU_SHARE_DIR (hwndDlg, wParam, lParam));
  1557. case NCDU_BROWSE_DIST_PATH:
  1558. return (ShareNetSwDlg_NCDU_BROWSE_DIST_PATH (hwndDlg, wParam, lParam));
  1559. case NCDU_VALIDATE_AND_END:
  1560. return (ShareNetSwDlg_NCDU_VALIDATE_AND_END (hwndDlg, wParam, lParam));
  1561. case WM_PAINT: return (Dlg_WM_PAINT (hwndDlg, wParam, lParam));
  1562. case WM_MOVE: return (Dlg_WM_MOVE (hwndDlg, wParam, lParam));
  1563. case WM_SYSCOMMAND: return (Dlg_WM_SYSCOMMAND (hwndDlg, wParam, lParam));
  1564. default: return FALSE;
  1565. }
  1566. }