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.

3624 lines
107 KiB

  1. #include "headers.hxx"
  2. #pragma hdrstop
  3. // We wouldn't have to do this if C's semantics for the stringizing macro
  4. // weren't so awful.
  5. #define APINAME_WNetConnectionDialog2 "WNetConnectionDialog2"
  6. #define APINAME_WNetDisconnectDialog2 "WNetDisconnectDialog2"
  7. #ifdef UNICODE
  8. #define APINAME_WNetGetConnection2 "WNetGetConnection2W"
  9. #define APINAME_WNetGetConnection3 "WNetGetConnection3W"
  10. #define APINAME_WNetGetProviderType "WNetGetProviderTypeW"
  11. #else
  12. #define APINAME_WNetGetConnection2 "WNetGetConnection2A"
  13. #define APINAME_WNetGetConnection3 "WNetGetConnection3A"
  14. #define APINAME_WNetGetProviderType "WNetGetProviderTypeA"
  15. #endif
  16. ////////////////////////////////////////////////////////////////
  17. TCHAR szMprDll[] = TEXT("mpr.dll");
  18. HINSTANCE g_hInstanceMpr = NULL; // if we need to manually load MPR
  19. typedef
  20. DWORD
  21. (*PFNWNETGETCONNECTION2)(
  22. LPTSTR lpLocalName,
  23. LPVOID lpBuffer,
  24. LPDWORD lpBufferSize
  25. );
  26. PFNWNETGETCONNECTION2 pfnWNetGetConnection2 = NULL;
  27. typedef
  28. DWORD
  29. (*PFNWNETGETCONNECTION3)(
  30. LPCTSTR lpLocalName,
  31. LPCTSTR lpProviderName,
  32. DWORD dwLevel,
  33. LPVOID lpBuffer,
  34. LPDWORD lpBufferSize
  35. );
  36. PFNWNETGETCONNECTION3 pfnWNetGetConnection3 = NULL;
  37. typedef
  38. DWORD
  39. (*PFNWNETGETPROVIDERTYPE)(
  40. LPCTSTR lpProvider,
  41. LPDWORD lpdwNetType
  42. );
  43. PFNWNETGETPROVIDERTYPE pfnWNetGetProviderType = NULL;
  44. typedef
  45. DWORD
  46. (*PFNWNETCONNECTIONDIALOG2)(
  47. HWND hwndParent,
  48. DWORD dwType,
  49. WCHAR *lpHelpFile,
  50. DWORD nHelpContext
  51. );
  52. PFNWNETCONNECTIONDIALOG2 pfnWNetConnectionDialog2 = NULL;
  53. typedef
  54. DWORD
  55. (*PFNWNETDISCONNECTDIALOG2)(
  56. HWND hwndParent,
  57. DWORD dwType,
  58. WCHAR *lpHelpFile,
  59. DWORD nHelpContext
  60. );
  61. PFNWNETDISCONNECTDIALOG2 pfnWNetDisconnectDialog2 = NULL;
  62. ////////////////////////////////////////////////////////////////
  63. TCHAR szMprUIDll[] = TEXT("mprui.dll");
  64. HINSTANCE g_hInstanceMprUI = NULL; // if we need to manually load MPRUI
  65. typedef
  66. BOOL
  67. (*PFUNC_VALIDATION_CALLBACK)(
  68. LPWSTR pszName
  69. );
  70. typedef
  71. DWORD
  72. (*PFNWNETBROWSEDIALOG)(
  73. HWND hwndParent,
  74. DWORD dwType,
  75. WCHAR *lpszName,
  76. DWORD cchBufSize,
  77. WCHAR *lpszHelpFile,
  78. DWORD nHelpContext,
  79. PFUNC_VALIDATION_CALLBACK pfuncValidation
  80. );
  81. PFNWNETBROWSEDIALOG pfnWNetBrowseDialog = NULL;
  82. ////////////////////////////////////////////////////////////////
  83. HINSTANCE g_hInstance;
  84. ////////////////////////////////////////////////////////////////
  85. VOID
  86. PlaceIt(
  87. HWND hwnd
  88. )
  89. {
  90. SetForegroundWindow(hwnd);
  91. // Use a trick from the property sheet code to properly place the dialog.
  92. // Basically, we want it to go wherever a new window would have gone, not
  93. // always in the upper-left corner of the screen. This avoids the problem
  94. // of multiple dialogs showing up in the same place on the screen,
  95. // overlapping each other.
  96. const TCHAR c_szStatic[] = TEXT("Static");
  97. HWND hwndT = CreateWindowEx(0, c_szStatic, NULL,
  98. WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT,
  99. 0, 0, NULL, NULL, g_hInstance, NULL);
  100. if (hwndT)
  101. {
  102. RECT rc;
  103. GetWindowRect(hwndT, &rc);
  104. DestroyWindow(hwndT);
  105. SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
  106. }
  107. }
  108. ////////////////////////////////////////////////////////////////
  109. // load up the MPR.DLL and get its entrypoints.
  110. // Return WN_SUCCESS if ok, else error. Note that we will return success even
  111. // if we can't find a particular entrypoint. This allows dynamically loading
  112. // entrypoints that exist on one platform/version but not on another.
  113. DWORD
  114. LoadMpr(
  115. VOID
  116. )
  117. {
  118. if (NULL != g_hInstanceMpr)
  119. {
  120. return WN_SUCCESS; // already loaded
  121. }
  122. g_hInstanceMpr = LoadLibrary(szMprDll);
  123. if (NULL == g_hInstanceMpr)
  124. {
  125. return GetLastError();
  126. }
  127. pfnWNetGetConnection2 = (PFNWNETGETCONNECTION2)GetProcAddress(g_hInstanceMpr, APINAME_WNetGetConnection2);
  128. pfnWNetGetConnection3 = (PFNWNETGETCONNECTION3)GetProcAddress(g_hInstanceMpr, APINAME_WNetGetConnection3);
  129. pfnWNetGetProviderType = (PFNWNETGETPROVIDERTYPE)GetProcAddress(g_hInstanceMpr, APINAME_WNetGetProviderType);
  130. pfnWNetConnectionDialog2 = (PFNWNETCONNECTIONDIALOG2)GetProcAddress(g_hInstanceMpr, APINAME_WNetConnectionDialog2);
  131. pfnWNetDisconnectDialog2 = (PFNWNETDISCONNECTDIALOG2)GetProcAddress(g_hInstanceMpr, APINAME_WNetDisconnectDialog2);
  132. return WN_SUCCESS;
  133. }
  134. // load up the MPRUI.DLL and get its entrypoints. Return WN_SUCCESS if ok, else error
  135. DWORD
  136. LoadMprUI(
  137. VOID
  138. )
  139. {
  140. if (NULL != g_hInstanceMprUI)
  141. {
  142. return WN_SUCCESS; // already loaded
  143. }
  144. g_hInstanceMprUI = LoadLibrary(szMprUIDll);
  145. if (NULL == g_hInstanceMprUI)
  146. {
  147. return GetLastError();
  148. }
  149. pfnWNetBrowseDialog = (PFNWNETBROWSEDIALOG)GetProcAddress(g_hInstanceMprUI, "WNetBrowseDialog");
  150. return WN_SUCCESS;
  151. }
  152. VOID
  153. GetUsageString(
  154. IN LPTSTR pszBuf, // better be big enough!
  155. IN LPNETRESOURCE pnr
  156. )
  157. {
  158. TCHAR szTemp[MAX_PATH];
  159. pszBuf[0] = TEXT('\0');
  160. DWORD dwUsage = pnr->dwUsage;
  161. if (0 != dwUsage)
  162. {
  163. wsprintf(szTemp, TEXT("%d: "), dwUsage);
  164. _tcscat(pszBuf, szTemp);
  165. }
  166. if (dwUsage & RESOURCEUSAGE_CONNECTABLE)
  167. {
  168. wsprintf(szTemp, TEXT("connectable (%d) "), RESOURCEUSAGE_CONNECTABLE);
  169. _tcscat(pszBuf, szTemp);
  170. dwUsage &= ~RESOURCEUSAGE_CONNECTABLE;
  171. }
  172. if (dwUsage & RESOURCEUSAGE_CONTAINER)
  173. {
  174. wsprintf(szTemp, TEXT("container (%d) "), RESOURCEUSAGE_CONTAINER);
  175. _tcscat(pszBuf, szTemp);
  176. dwUsage &= ~RESOURCEUSAGE_CONTAINER;
  177. }
  178. if (dwUsage & RESOURCEUSAGE_NOLOCALDEVICE)
  179. {
  180. wsprintf(szTemp, TEXT("no local device (%d) "), RESOURCEUSAGE_NOLOCALDEVICE);
  181. _tcscat(pszBuf, szTemp);
  182. dwUsage &= ~RESOURCEUSAGE_NOLOCALDEVICE;
  183. }
  184. if (dwUsage & RESOURCEUSAGE_SIBLING)
  185. {
  186. wsprintf(szTemp, TEXT("sibling (%d) "), RESOURCEUSAGE_SIBLING);
  187. _tcscat(pszBuf, szTemp);
  188. dwUsage &= ~RESOURCEUSAGE_SIBLING;
  189. }
  190. if (dwUsage & RESOURCEUSAGE_RESERVED)
  191. {
  192. wsprintf(szTemp, TEXT("reserved (%d) "), RESOURCEUSAGE_RESERVED);
  193. _tcscat(pszBuf, szTemp);
  194. dwUsage &= ~RESOURCEUSAGE_RESERVED;
  195. }
  196. if (dwUsage != 0)
  197. {
  198. wsprintf(pszBuf, TEXT("UNKNOWN (%d) "), dwUsage);
  199. }
  200. }
  201. VOID
  202. GetScopeString(
  203. IN LPTSTR pszBuf, // better be big enough!
  204. IN LPNETRESOURCE pnr
  205. )
  206. {
  207. LPTSTR pszT;
  208. switch (pnr->dwScope)
  209. {
  210. case RESOURCE_CONNECTED: pszT = TEXT("connected"); break;
  211. case RESOURCE_GLOBALNET: pszT = TEXT("globalnet"); break;
  212. case RESOURCE_REMEMBERED: pszT = TEXT("remembered"); break;
  213. case RESOURCE_RECENT: pszT = TEXT("recent"); break;
  214. case RESOURCE_CONTEXT: pszT = TEXT("context"); break;
  215. default: pszT = TEXT("UNKNOWN"); break;
  216. }
  217. wsprintf(pszBuf, TEXT("%s (%d)"), pszT, pnr->dwScope);
  218. }
  219. VOID
  220. GetTypeString(
  221. IN LPTSTR pszBuf, // better be big enough!
  222. IN LPNETRESOURCE pnr
  223. )
  224. {
  225. LPTSTR pszT;
  226. switch (pnr->dwType)
  227. {
  228. case RESOURCETYPE_ANY: pszT = TEXT("any"); break;
  229. case RESOURCETYPE_DISK: pszT = TEXT("disk"); break;
  230. case RESOURCETYPE_PRINT: pszT = TEXT("print"); break;
  231. case RESOURCETYPE_RESERVED: pszT = TEXT("reserved"); break;
  232. case RESOURCETYPE_UNKNOWN: pszT = TEXT("unknown"); break;
  233. default: pszT = TEXT("UNKNOWN"); break;
  234. }
  235. wsprintf(pszBuf, TEXT("%s (%d)"), pszT, pnr->dwType);
  236. }
  237. VOID
  238. GetDisplayTypeString(
  239. IN LPTSTR pszBuf, // better be big enough!
  240. IN LPNETRESOURCE pnr
  241. )
  242. {
  243. LPTSTR pszT;
  244. switch (pnr->dwDisplayType)
  245. {
  246. case RESOURCEDISPLAYTYPE_GENERIC: pszT = TEXT("generic"); break;
  247. case RESOURCEDISPLAYTYPE_DOMAIN: pszT = TEXT("domain"); break;
  248. case RESOURCEDISPLAYTYPE_SERVER: pszT = TEXT("server"); break;
  249. case RESOURCEDISPLAYTYPE_SHARE: pszT = TEXT("share"); break;
  250. case RESOURCEDISPLAYTYPE_FILE: pszT = TEXT("file"); break;
  251. case RESOURCEDISPLAYTYPE_GROUP: pszT = TEXT("group"); break;
  252. case RESOURCEDISPLAYTYPE_NETWORK: pszT = TEXT("network"); break;
  253. case RESOURCEDISPLAYTYPE_ROOT: pszT = TEXT("root"); break;
  254. case RESOURCEDISPLAYTYPE_SHAREADMIN: pszT = TEXT("shareadmin"); break;
  255. case RESOURCEDISPLAYTYPE_DIRECTORY: pszT = TEXT("directory"); break;
  256. case RESOURCEDISPLAYTYPE_TREE: pszT = TEXT("tree"); break;
  257. default: pszT = TEXT("UNKNOWN"); break;
  258. }
  259. wsprintf(pszBuf, TEXT("%s (%d)"), pszT, pnr->dwDisplayType);
  260. }
  261. VOID
  262. DoError(
  263. HWND hwnd,
  264. DWORD dwErr
  265. )
  266. {
  267. TCHAR sz[500];
  268. if (dwErr == WN_EXTENDED_ERROR)
  269. {
  270. DWORD npErr;
  271. TCHAR szNpErr[500];
  272. TCHAR szNpName[500];
  273. DWORD dw = WNetGetLastError(&npErr, szNpErr, ARRAYLEN(szNpErr), szNpName, ARRAYLEN(szNpName));
  274. if (dw == WN_SUCCESS)
  275. {
  276. wsprintf(sz,
  277. TEXT("WN_EXTENDED_ERROR: %d, %s (%s)"),
  278. npErr,
  279. szNpErr,
  280. szNpName);
  281. }
  282. else
  283. {
  284. wsprintf(sz,
  285. TEXT("WN_EXTENDED_ERROR: WNetGetLastError error %d"),
  286. dw);
  287. }
  288. SetDlgItemText(hwnd, IDC_ERROR, sz);
  289. }
  290. else
  291. {
  292. wsprintf(sz, TEXT("%d (0x%08lx) "), dwErr, dwErr);
  293. TCHAR szBuffer[MAX_PATH];
  294. DWORD dwBufferSize = ARRAYLEN(szBuffer);
  295. DWORD dwReturn = FormatMessage(
  296. FORMAT_MESSAGE_FROM_SYSTEM,
  297. NULL,
  298. dwErr,
  299. LANG_SYSTEM_DEFAULT,
  300. szBuffer,
  301. dwBufferSize,
  302. NULL);
  303. if (0 == dwReturn)
  304. {
  305. // couldn't find message
  306. _tcscat(sz, TEXT("unknown error"));
  307. }
  308. else
  309. {
  310. _tcscat(sz, szBuffer);
  311. }
  312. SetDlgItemText(hwnd, IDC_ERROR, sz);
  313. }
  314. if (dwErr != WN_SUCCESS && dwErr != 0xffffffff)
  315. {
  316. Beep(1000, 150);
  317. }
  318. }
  319. INT_PTR CALLBACK
  320. Connection1DlgProc(
  321. IN HWND hwnd,
  322. IN UINT uMsg,
  323. IN WPARAM wParam,
  324. IN LPARAM lParam
  325. )
  326. {
  327. static int options[] =
  328. {
  329. IDC_RO_PATH,
  330. IDC_USE_MRU,
  331. IDC_HIDE_BOX,
  332. IDC_PERSIST,
  333. IDC_NOT_PERSIST,
  334. IDC_CONN_POINT,
  335. IDC_YESPATH,
  336. IDC_NOPATH,
  337. IDC_DISK,
  338. IDC_PRINTER
  339. };
  340. switch (uMsg)
  341. {
  342. case WM_INITDIALOG:
  343. PlaceIt(hwnd);
  344. SetDlgItemText(hwnd, IDC_REMOTE_TEXT, TEXT("\\\\scratch\\scratch"));
  345. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  346. SetDlgItemText(hwnd, IDC_DEVICE, TEXT(""));
  347. CheckRadioButton(hwnd, IDC_YESPATH, IDC_NOPATH, IDC_YESPATH);
  348. CheckRadioButton(hwnd, IDC_DISK, IDC_PRINTER, IDC_DISK);
  349. return 1; // didn't call SetFocus
  350. case WM_COMMAND:
  351. {
  352. switch (LOWORD(wParam))
  353. {
  354. case IDC_GO:
  355. {
  356. LPCONNECTDLGSTRUCT lpConnDlgStruct;
  357. CONNECTDLGSTRUCT conn;
  358. if (1 == IsDlgButtonChecked(hwnd, IDC_NULL))
  359. {
  360. lpConnDlgStruct = NULL;
  361. }
  362. else
  363. {
  364. // get the flags
  365. DWORD dwFlags = 0;
  366. if (1 == IsDlgButtonChecked(hwnd, IDC_RO_PATH))
  367. {
  368. dwFlags |= CONNDLG_RO_PATH;
  369. }
  370. if (1 == IsDlgButtonChecked(hwnd, IDC_USE_MRU))
  371. {
  372. dwFlags |= CONNDLG_USE_MRU;
  373. }
  374. if (1 == IsDlgButtonChecked(hwnd, IDC_HIDE_BOX))
  375. {
  376. dwFlags |= CONNDLG_HIDE_BOX;
  377. }
  378. if (1 == IsDlgButtonChecked(hwnd, IDC_PERSIST))
  379. {
  380. dwFlags |= CONNDLG_PERSIST;
  381. }
  382. if (1 == IsDlgButtonChecked(hwnd, IDC_NOT_PERSIST))
  383. {
  384. dwFlags |= CONNDLG_NOT_PERSIST;
  385. }
  386. if (1 == IsDlgButtonChecked(hwnd, IDC_CONN_POINT))
  387. {
  388. dwFlags |= CONNDLG_CONN_POINT;
  389. }
  390. TCHAR szRemoteName[200];
  391. LPTSTR pszRemoteName = NULL;
  392. if (1 == IsDlgButtonChecked(hwnd, IDC_YESPATH))
  393. {
  394. GetDlgItemText(hwnd, IDC_REMOTE_TEXT, szRemoteName, ARRAYLEN(szRemoteName));
  395. pszRemoteName = szRemoteName;
  396. }
  397. else
  398. {
  399. pszRemoteName = NULL;
  400. }
  401. DWORD dwType = 0;
  402. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  403. {
  404. dwType = RESOURCETYPE_DISK;
  405. }
  406. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  407. {
  408. dwType = RESOURCETYPE_PRINT;
  409. }
  410. else
  411. {
  412. // internal error
  413. }
  414. NETRESOURCE net;
  415. conn.cbStructure = sizeof(conn);
  416. conn.hwndOwner = hwnd;
  417. conn.lpConnRes = &net;
  418. conn.dwFlags = dwFlags;
  419. conn.dwDevNum = 999; // initialize to something recognizable
  420. net.dwScope = 0;
  421. net.dwType = dwType;
  422. net.dwDisplayType = 0;
  423. net.dwUsage = 0;
  424. net.lpLocalName = NULL;
  425. net.lpRemoteName = pszRemoteName;
  426. net.lpComment = NULL;
  427. net.lpProvider = NULL;
  428. lpConnDlgStruct = &conn;
  429. }
  430. // clear it
  431. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  432. SetDlgItemText(hwnd, IDC_DEVICE, TEXT(""));
  433. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  434. DWORD dw = WNetConnectionDialog1(lpConnDlgStruct);
  435. SetCursor(hOldCursor);
  436. TCHAR sz[500];
  437. sz[0] = L'\0';
  438. if (NULL != lpConnDlgStruct)
  439. {
  440. wsprintf(sz, TEXT("%d"), lpConnDlgStruct->dwDevNum);
  441. }
  442. SetDlgItemText(hwnd, IDC_DEVICE, sz);
  443. DoError(hwnd, dw);
  444. return TRUE;
  445. }
  446. case IDOK:
  447. EndDialog(hwnd, TRUE);
  448. return TRUE;
  449. case IDC_NULL:
  450. {
  451. BOOL bOn = (BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_NULL));
  452. for (int i = 0; i < ARRAYLEN(options); i++)
  453. {
  454. EnableWindow(GetDlgItem(hwnd, options[i]), bOn);
  455. }
  456. return TRUE;
  457. }
  458. }
  459. return FALSE;
  460. }
  461. default:
  462. return FALSE; // didn't process
  463. }
  464. }
  465. INT_PTR CALLBACK
  466. Disconnect1DlgProc(
  467. IN HWND hwnd,
  468. IN UINT uMsg,
  469. IN WPARAM wParam,
  470. IN LPARAM lParam
  471. )
  472. {
  473. static int options[] =
  474. {
  475. IDC_UPDATE_PROFILE,
  476. IDC_NO_FORCE,
  477. IDC_LOCAL,
  478. IDC_REMOTE
  479. };
  480. switch (uMsg)
  481. {
  482. case WM_INITDIALOG:
  483. PlaceIt(hwnd);
  484. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  485. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  486. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT), FALSE);
  487. CheckDlgButton(hwnd, IDC_LOCAL_TEXT, 0);
  488. SetDlgItemText(hwnd, IDC_REMOTE_TEXT, TEXT(""));
  489. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT), FALSE);
  490. CheckDlgButton(hwnd, IDC_REMOTE_TEXT, 0);
  491. CheckDlgButton(hwnd, IDC_UPDATE_PROFILE, 0);
  492. CheckDlgButton(hwnd, IDC_NO_FORCE, 0);
  493. return 1; // didn't call SetFocus
  494. case WM_COMMAND:
  495. {
  496. switch (LOWORD(wParam))
  497. {
  498. case IDC_GO:
  499. {
  500. LPDISCDLGSTRUCT lpDiscDlgStruct;
  501. DISCDLGSTRUCT disc;
  502. if (1 == IsDlgButtonChecked(hwnd, IDC_NULL))
  503. {
  504. lpDiscDlgStruct = NULL;
  505. }
  506. else
  507. {
  508. // get the flags
  509. DWORD dwFlags = 0;
  510. if (1 == IsDlgButtonChecked(hwnd, IDC_UPDATE_PROFILE))
  511. {
  512. dwFlags |= DISC_UPDATE_PROFILE;
  513. }
  514. if (1 == IsDlgButtonChecked(hwnd, IDC_NO_FORCE))
  515. {
  516. dwFlags |= DISC_NO_FORCE;
  517. }
  518. TCHAR szLocalName[200];
  519. LPTSTR pszLocalName = NULL;
  520. if (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL))
  521. {
  522. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  523. pszLocalName = szLocalName;
  524. }
  525. TCHAR szRemoteName[200];
  526. LPTSTR pszRemoteName = NULL;
  527. if (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE))
  528. {
  529. GetDlgItemText(hwnd, IDC_REMOTE_TEXT, szRemoteName, ARRAYLEN(szRemoteName));
  530. pszRemoteName = szRemoteName;
  531. }
  532. disc.cbStructure = sizeof(disc);
  533. disc.hwndOwner = hwnd;
  534. disc.lpLocalName = pszLocalName;
  535. disc.lpRemoteName = pszRemoteName;
  536. disc.dwFlags = dwFlags;
  537. lpDiscDlgStruct = &disc;
  538. }
  539. // clear it
  540. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  541. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  542. DWORD dw = WNetDisconnectDialog1(lpDiscDlgStruct);
  543. SetCursor(hOldCursor);
  544. DoError(hwnd, dw);
  545. return TRUE;
  546. }
  547. case IDOK:
  548. EndDialog(hwnd, TRUE);
  549. return TRUE;
  550. case IDC_LOCAL:
  551. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT),
  552. (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL)));
  553. break;
  554. case IDC_REMOTE:
  555. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT),
  556. (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE)));
  557. break;
  558. case IDC_NULL:
  559. {
  560. BOOL bOn = (BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_NULL));
  561. for (int i = 0; i < ARRAYLEN(options); i++)
  562. {
  563. EnableWindow(GetDlgItem(hwnd, options[i]), bOn);
  564. }
  565. // special handling of text fields:
  566. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT),
  567. bOn && (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL)));
  568. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT),
  569. bOn && (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE)));
  570. return TRUE;
  571. }
  572. }
  573. return FALSE;
  574. }
  575. default:
  576. return FALSE; // didn't process
  577. }
  578. }
  579. INT_PTR CALLBACK
  580. ConnectionDlgProc(
  581. IN HWND hwnd,
  582. IN UINT uMsg,
  583. IN WPARAM wParam,
  584. IN LPARAM lParam
  585. )
  586. {
  587. switch (uMsg)
  588. {
  589. case WM_INITDIALOG:
  590. PlaceIt(hwnd);
  591. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  592. CheckRadioButton(hwnd, IDC_DISK, IDC_PRINTER, IDC_DISK);
  593. return 1; // didn't call SetFocus
  594. case WM_COMMAND:
  595. {
  596. switch (LOWORD(wParam))
  597. {
  598. case IDC_GO:
  599. {
  600. DWORD dwType = 0;
  601. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  602. {
  603. dwType = RESOURCETYPE_DISK;
  604. }
  605. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  606. {
  607. dwType = RESOURCETYPE_PRINT;
  608. }
  609. else
  610. {
  611. // internal error
  612. }
  613. // clear it
  614. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  615. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  616. DWORD dw = WNetConnectionDialog(hwnd, dwType);
  617. SetCursor(hOldCursor);
  618. DoError(hwnd, dw);
  619. return TRUE;
  620. }
  621. case IDOK:
  622. EndDialog(hwnd, TRUE);
  623. return TRUE;
  624. }
  625. return FALSE;
  626. }
  627. default:
  628. return FALSE; // didn't process
  629. }
  630. }
  631. INT_PTR CALLBACK
  632. DisconnectDlgProc(
  633. IN HWND hwnd,
  634. IN UINT uMsg,
  635. IN WPARAM wParam,
  636. IN LPARAM lParam
  637. )
  638. {
  639. switch (uMsg)
  640. {
  641. case WM_INITDIALOG:
  642. PlaceIt(hwnd);
  643. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  644. CheckRadioButton(hwnd, IDC_DISK, IDC_PRINTER, IDC_DISK);
  645. return 1; // didn't call SetFocus
  646. case WM_COMMAND:
  647. {
  648. switch (LOWORD(wParam))
  649. {
  650. case IDC_GO:
  651. {
  652. DWORD dwType = 0;
  653. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  654. {
  655. dwType = RESOURCETYPE_DISK;
  656. }
  657. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  658. {
  659. dwType = RESOURCETYPE_PRINT;
  660. }
  661. else
  662. {
  663. // internal error
  664. }
  665. // clear it
  666. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  667. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  668. DWORD dw = WNetDisconnectDialog(hwnd, dwType);
  669. SetCursor(hOldCursor);
  670. DoError(hwnd, dw);
  671. return TRUE;
  672. }
  673. case IDOK:
  674. EndDialog(hwnd, TRUE);
  675. return TRUE;
  676. }
  677. return FALSE;
  678. }
  679. default:
  680. return FALSE; // didn't process
  681. }
  682. }
  683. INT_PTR CALLBACK
  684. Connection2DlgProc(
  685. IN HWND hwnd,
  686. IN UINT uMsg,
  687. IN WPARAM wParam,
  688. IN LPARAM lParam
  689. )
  690. {
  691. switch (uMsg)
  692. {
  693. case WM_INITDIALOG:
  694. PlaceIt(hwnd);
  695. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  696. SetDlgItemText(hwnd, IDC_HELPFILE, TEXT("winfile.hlp"));
  697. SetDlgItemText(hwnd, IDC_HELPINDEX, TEXT("5205"));
  698. CheckRadioButton(hwnd, IDC_DISK, IDC_PRINTER, IDC_DISK);
  699. return 1; // didn't call SetFocus
  700. case WM_COMMAND:
  701. {
  702. switch (LOWORD(wParam))
  703. {
  704. case IDC_GO:
  705. {
  706. DWORD dwType = 0;
  707. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  708. {
  709. dwType = RESOURCETYPE_DISK;
  710. }
  711. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  712. {
  713. dwType = RESOURCETYPE_PRINT;
  714. }
  715. else
  716. {
  717. // internal error
  718. }
  719. WCHAR szHelpFile[200];
  720. GetDlgItemTextW(hwnd, IDC_HELPFILE, szHelpFile, ARRAYLEN(szHelpFile));
  721. DWORD nHelpContext = 5205; // default
  722. BOOL translated;
  723. UINT uhelp = GetDlgItemInt(hwnd, IDC_HELPINDEX, &translated, FALSE);
  724. if (translated)
  725. {
  726. nHelpContext = uhelp;
  727. }
  728. // clear it
  729. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  730. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  731. DWORD dw = LoadMpr();
  732. if (dw == WN_SUCCESS)
  733. {
  734. if (NULL == pfnWNetConnectionDialog2)
  735. {
  736. dw = ERROR_PROC_NOT_FOUND;
  737. }
  738. else
  739. {
  740. dw = (*pfnWNetConnectionDialog2)(hwnd, dwType, szHelpFile, nHelpContext);
  741. }
  742. }
  743. SetCursor(hOldCursor);
  744. DoError(hwnd, dw);
  745. return TRUE;
  746. }
  747. case IDOK:
  748. EndDialog(hwnd, TRUE);
  749. return TRUE;
  750. }
  751. return FALSE;
  752. }
  753. default:
  754. return FALSE; // didn't process
  755. }
  756. }
  757. INT_PTR CALLBACK
  758. Disconnect2DlgProc(
  759. IN HWND hwnd,
  760. IN UINT uMsg,
  761. IN WPARAM wParam,
  762. IN LPARAM lParam
  763. )
  764. {
  765. switch (uMsg)
  766. {
  767. case WM_INITDIALOG:
  768. PlaceIt(hwnd);
  769. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  770. SetDlgItemText(hwnd, IDC_HELPFILE, TEXT("winfile.hlp"));
  771. SetDlgItemText(hwnd, IDC_HELPINDEX, TEXT("5206"));
  772. CheckRadioButton(hwnd, IDC_DISK, IDC_PRINTER, IDC_DISK);
  773. return 1; // didn't call SetFocus
  774. case WM_COMMAND:
  775. {
  776. switch (LOWORD(wParam))
  777. {
  778. case IDC_GO:
  779. {
  780. DWORD dwType = 0;
  781. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  782. {
  783. dwType = RESOURCETYPE_DISK;
  784. }
  785. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  786. {
  787. dwType = RESOURCETYPE_PRINT;
  788. }
  789. else
  790. {
  791. // internal error
  792. }
  793. WCHAR szHelpFile[200];
  794. GetDlgItemTextW(hwnd, IDC_HELPFILE, szHelpFile, ARRAYLEN(szHelpFile));
  795. DWORD nHelpContext = 5206; // default
  796. BOOL translated;
  797. UINT uhelp = GetDlgItemInt(hwnd, IDC_HELPINDEX, &translated, FALSE);
  798. if (translated)
  799. {
  800. nHelpContext = uhelp;
  801. }
  802. // clear it
  803. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  804. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  805. DWORD dw = LoadMpr();
  806. if (dw == WN_SUCCESS)
  807. {
  808. if (NULL == pfnWNetDisconnectDialog2)
  809. {
  810. dw = ERROR_PROC_NOT_FOUND;
  811. }
  812. else
  813. {
  814. dw = (*pfnWNetDisconnectDialog2)(hwnd, dwType, szHelpFile, nHelpContext);
  815. }
  816. }
  817. SetCursor(hOldCursor);
  818. DoError(hwnd, dw);
  819. return TRUE;
  820. }
  821. case IDOK:
  822. EndDialog(hwnd, TRUE);
  823. return TRUE;
  824. }
  825. return FALSE;
  826. }
  827. default:
  828. return FALSE; // didn't process
  829. }
  830. }
  831. BOOL
  832. BrowseValidationCallback(
  833. LPWSTR pszName
  834. )
  835. {
  836. return TRUE;
  837. }
  838. INT_PTR CALLBACK
  839. BrowseDlgProc(
  840. IN HWND hwnd,
  841. IN UINT uMsg,
  842. IN WPARAM wParam,
  843. IN LPARAM lParam
  844. )
  845. {
  846. switch (uMsg)
  847. {
  848. case WM_INITDIALOG:
  849. PlaceIt(hwnd);
  850. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  851. SetDlgItemText(hwnd, IDC_BROWSE_NAME, TEXT(""));
  852. CheckRadioButton(hwnd, IDC_DISK, IDC_PRINTER, IDC_DISK);
  853. return 1; // didn't call SetFocus
  854. case WM_COMMAND:
  855. {
  856. switch (LOWORD(wParam))
  857. {
  858. case IDC_GO:
  859. {
  860. DWORD dwType = 0;
  861. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  862. {
  863. dwType = RESOURCETYPE_DISK;
  864. }
  865. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  866. {
  867. dwType = RESOURCETYPE_PRINT;
  868. }
  869. else
  870. {
  871. // internal error
  872. }
  873. // clear it
  874. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  875. SetDlgItemText(hwnd, IDC_BROWSE_NAME, TEXT(""));
  876. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  877. WCHAR szName[MAX_PATH];
  878. DWORD dw = LoadMprUI();
  879. if (dw == WN_SUCCESS)
  880. {
  881. if (NULL == pfnWNetBrowseDialog)
  882. {
  883. dw = ERROR_PROC_NOT_FOUND;
  884. }
  885. else
  886. {
  887. dw = (*pfnWNetBrowseDialog)(
  888. hwnd,
  889. dwType,
  890. szName,
  891. ARRAYLEN(szName),
  892. L"help.hlp", // help file
  893. 0, // help context
  894. &BrowseValidationCallback);
  895. }
  896. }
  897. SetCursor(hOldCursor);
  898. if (dw == WN_SUCCESS)
  899. {
  900. SetDlgItemTextW(hwnd, IDC_BROWSE_NAME, szName);
  901. }
  902. DoError(hwnd, dw);
  903. return TRUE;
  904. }
  905. case IDOK:
  906. EndDialog(hwnd, TRUE);
  907. return TRUE;
  908. }
  909. return FALSE;
  910. }
  911. default:
  912. return FALSE; // didn't process
  913. }
  914. }
  915. INT_PTR CALLBACK
  916. GetConnectionDlgProc(
  917. IN HWND hwnd,
  918. IN UINT uMsg,
  919. IN WPARAM wParam,
  920. IN LPARAM lParam
  921. )
  922. {
  923. switch (uMsg)
  924. {
  925. case WM_INITDIALOG:
  926. PlaceIt(hwnd);
  927. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  928. SetDlgItemText(hwnd, IDC_REMOTE, TEXT(""));
  929. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  930. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  931. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  932. return 1; // didn't call SetFocus
  933. case WM_COMMAND:
  934. {
  935. switch (LOWORD(wParam))
  936. {
  937. case IDC_GO:
  938. {
  939. TCHAR szLocalName[200];
  940. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  941. TCHAR szReturn[MAX_PATH];
  942. DWORD bufSize = ARRAYLEN(szReturn);
  943. DWORD bufSizeIn = bufSize;
  944. // clear it
  945. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  946. SetDlgItemText(hwnd, IDC_REMOTE, TEXT(""));
  947. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  948. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  949. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  950. DWORD dw = WNetGetConnection(szLocalName, szReturn, &bufSize);
  951. SetCursor(hOldCursor);
  952. if (dw == WN_SUCCESS ||
  953. dw == WN_CONNECTION_CLOSED)
  954. {
  955. SetDlgItemText(hwnd, IDC_REMOTE, szReturn);
  956. }
  957. else
  958. {
  959. SetDlgItemText(hwnd, IDC_REMOTE, TEXT(""));
  960. }
  961. TCHAR sz[500];
  962. wsprintf(sz, TEXT("%d"), bufSize);
  963. SetDlgItemText(hwnd, IDC_BUFSIZE, sz);
  964. wsprintf(sz, TEXT("%d"), bufSizeIn);
  965. SetDlgItemText(hwnd, IDC_BUFSIZEIN, sz);
  966. DoError(hwnd, dw);
  967. return TRUE;
  968. }
  969. case IDOK:
  970. EndDialog(hwnd, TRUE);
  971. return TRUE;
  972. }
  973. return FALSE;
  974. }
  975. default:
  976. return FALSE; // didn't process
  977. }
  978. }
  979. INT_PTR CALLBACK
  980. GetConnectionDlgProc2(
  981. IN HWND hwnd,
  982. IN UINT uMsg,
  983. IN WPARAM wParam,
  984. IN LPARAM lParam
  985. )
  986. {
  987. switch (uMsg)
  988. {
  989. case WM_INITDIALOG:
  990. PlaceIt(hwnd);
  991. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  992. SetDlgItemText(hwnd, IDC_REMOTE, TEXT(""));
  993. SetDlgItemText(hwnd, IDC_PROVIDER, TEXT(""));
  994. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  995. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  996. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  997. return 1; // didn't call SetFocus
  998. case WM_COMMAND:
  999. {
  1000. switch (LOWORD(wParam))
  1001. {
  1002. case IDC_GO:
  1003. {
  1004. TCHAR szLocalName[200];
  1005. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  1006. BYTE buf[MAX_PATH*2 + sizeof(WNET_CONNECTIONINFO)];
  1007. WNET_CONNECTIONINFO* pInfo = (WNET_CONNECTIONINFO*)buf;
  1008. DWORD bufSize = sizeof(buf);
  1009. DWORD bufSizeIn = bufSize;
  1010. // clear it
  1011. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1012. SetDlgItemText(hwnd, IDC_REMOTE, TEXT(""));
  1013. SetDlgItemText(hwnd, IDC_PROVIDER, TEXT(""));
  1014. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  1015. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  1016. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1017. DWORD dw = LoadMpr();
  1018. if (dw == WN_SUCCESS)
  1019. {
  1020. if (NULL == pfnWNetGetConnection2)
  1021. {
  1022. dw = ERROR_PROC_NOT_FOUND;
  1023. }
  1024. else
  1025. {
  1026. dw = (*pfnWNetGetConnection2)(szLocalName, (LPVOID)buf, &bufSize);
  1027. }
  1028. }
  1029. SetCursor(hOldCursor);
  1030. if (dw == WN_SUCCESS ||
  1031. dw == WN_CONNECTION_CLOSED)
  1032. {
  1033. SetDlgItemText(hwnd, IDC_REMOTE, pInfo->lpRemoteName);
  1034. SetDlgItemText(hwnd, IDC_PROVIDER, pInfo->lpProvider);
  1035. }
  1036. else
  1037. {
  1038. SetDlgItemText(hwnd, IDC_REMOTE, TEXT(""));
  1039. SetDlgItemText(hwnd, IDC_PROVIDER, TEXT(""));
  1040. }
  1041. TCHAR sz[500];
  1042. wsprintf(sz, TEXT("%d"), bufSize);
  1043. SetDlgItemText(hwnd, IDC_BUFSIZE, sz);
  1044. wsprintf(sz, TEXT("%d"), bufSizeIn);
  1045. SetDlgItemText(hwnd, IDC_BUFSIZEIN, sz);
  1046. DoError(hwnd, dw);
  1047. return TRUE;
  1048. }
  1049. case IDOK:
  1050. EndDialog(hwnd, TRUE);
  1051. return TRUE;
  1052. }
  1053. return FALSE;
  1054. }
  1055. default:
  1056. return FALSE; // didn't process
  1057. }
  1058. }
  1059. INT_PTR CALLBACK
  1060. GetConnection3DlgProc(
  1061. IN HWND hwnd,
  1062. IN UINT uMsg,
  1063. IN WPARAM wParam,
  1064. IN LPARAM lParam
  1065. )
  1066. {
  1067. switch (uMsg)
  1068. {
  1069. case WM_INITDIALOG:
  1070. PlaceIt(hwnd);
  1071. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1072. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  1073. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT), FALSE);
  1074. CheckDlgButton(hwnd, IDC_LOCAL_TEXT, 0);
  1075. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  1076. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT), FALSE);
  1077. CheckDlgButton(hwnd, IDC_PROVIDER_TEXT, 0);
  1078. SetDlgItemInt (hwnd, IDC_INFOLEVEL, 1, FALSE); // test level 1 only
  1079. SetDlgItemText(hwnd, IDC_RETURNFLAGS, TEXT(""));
  1080. SetDlgItemInt (hwnd, IDC_BUFSIZEIN, sizeof(DWORD), FALSE);
  1081. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  1082. return 1; // didn't call SetFocus
  1083. case WM_COMMAND:
  1084. {
  1085. switch (LOWORD(wParam))
  1086. {
  1087. case IDC_GO:
  1088. {
  1089. TCHAR szLocalName[200];
  1090. LPTSTR pszLocalName = NULL;
  1091. if (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL))
  1092. {
  1093. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  1094. pszLocalName = szLocalName;
  1095. }
  1096. TCHAR szProviderName[200];
  1097. LPTSTR pszProviderName = NULL;
  1098. if (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER))
  1099. {
  1100. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderName, ARRAYLEN(szProviderName));
  1101. pszProviderName = szProviderName;
  1102. }
  1103. WNGC_CONNECTION_STATE ConnState;
  1104. DWORD bufSizeIn = sizeof(ConnState);
  1105. DWORD bufSize = bufSizeIn;
  1106. // clear it
  1107. SetDlgItemText(hwnd, IDC_RETURNFLAGS, TEXT(""));
  1108. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  1109. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  1110. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1111. DWORD dw = LoadMpr();
  1112. if (dw == WN_SUCCESS)
  1113. {
  1114. if (NULL == pfnWNetGetConnection3)
  1115. {
  1116. dw = ERROR_PROC_NOT_FOUND;
  1117. }
  1118. else
  1119. {
  1120. dw = (*pfnWNetGetConnection3)(
  1121. pszLocalName,
  1122. pszProviderName,
  1123. WNGC_INFOLEVEL_DISCONNECTED, // level
  1124. &ConnState, // buffer
  1125. &bufSize // buffer size
  1126. );
  1127. }
  1128. }
  1129. SetCursor(hOldCursor);
  1130. DoError(hwnd, dw);
  1131. if (WN_SUCCESS == dw)
  1132. {
  1133. TCHAR szBuf[50];
  1134. wsprintf(szBuf, TEXT("%lu (%hs)"), ConnState,
  1135. (ConnState.dwState == WNGC_CONNECTED) ? "WNGC_CONNECTED" :
  1136. (ConnState.dwState == WNGC_DISCONNECTED) ? "WNGC_DISCONNECTED" :
  1137. "Unrecognized"
  1138. );
  1139. SetDlgItemText(hwnd, IDC_RETURNFLAGS, szBuf);
  1140. }
  1141. SetDlgItemInt(hwnd, IDC_BUFSIZEIN, bufSizeIn, FALSE);
  1142. SetDlgItemInt(hwnd, IDC_BUFSIZE , bufSize , FALSE);
  1143. return TRUE;
  1144. }
  1145. case IDOK:
  1146. EndDialog(hwnd, TRUE);
  1147. return TRUE;
  1148. case IDC_LOCAL:
  1149. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT),
  1150. (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL)));
  1151. return TRUE;
  1152. case IDC_PROVIDER:
  1153. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT),
  1154. (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER)));
  1155. return TRUE;
  1156. } // end switch (LOWORD(wParam))
  1157. return FALSE;
  1158. }
  1159. default:
  1160. return FALSE; // didn't process
  1161. }
  1162. }
  1163. INT_PTR CALLBACK
  1164. GetConnectionPerformanceDlgProc(
  1165. IN HWND hwnd,
  1166. IN UINT uMsg,
  1167. IN WPARAM wParam,
  1168. IN LPARAM lParam
  1169. )
  1170. {
  1171. switch (uMsg)
  1172. {
  1173. case WM_INITDIALOG:
  1174. PlaceIt(hwnd);
  1175. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1176. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  1177. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT), FALSE);
  1178. CheckDlgButton(hwnd, IDC_LOCAL_TEXT, 0);
  1179. SetDlgItemText(hwnd, IDC_REMOTE_TEXT, TEXT(""));
  1180. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT), FALSE);
  1181. CheckDlgButton(hwnd, IDC_REMOTE_TEXT, 0);
  1182. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  1183. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT), FALSE);
  1184. CheckDlgButton(hwnd, IDC_PROVIDER_TEXT, 0);
  1185. SetDlgItemText(hwnd, IDC_RETURNFLAGS, TEXT(""));
  1186. SetDlgItemText(hwnd, IDC_RETURNSPEED, TEXT(""));
  1187. SetDlgItemText(hwnd, IDC_RETURNDELAY, TEXT(""));
  1188. SetDlgItemText(hwnd, IDC_RETURNOPTDATASIZE, TEXT(""));
  1189. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  1190. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  1191. return 1; // didn't call SetFocus
  1192. case WM_COMMAND:
  1193. {
  1194. switch (LOWORD(wParam))
  1195. {
  1196. case IDC_GO:
  1197. {
  1198. TCHAR szLocalName[200];
  1199. LPTSTR pszLocalName = NULL;
  1200. if (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL))
  1201. {
  1202. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  1203. pszLocalName = szLocalName;
  1204. }
  1205. TCHAR szRemoteName[200];
  1206. LPTSTR pszRemoteName = NULL;
  1207. if (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE))
  1208. {
  1209. GetDlgItemText(hwnd, IDC_REMOTE_TEXT, szRemoteName, ARRAYLEN(szRemoteName));
  1210. pszRemoteName = szRemoteName;
  1211. }
  1212. TCHAR szProviderName[200];
  1213. LPTSTR pszProviderName = NULL;
  1214. if (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER))
  1215. {
  1216. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderName, ARRAYLEN(szProviderName));
  1217. pszProviderName = szProviderName;
  1218. }
  1219. NETRESOURCE net;
  1220. net.dwScope = 0;
  1221. net.dwType = 0;
  1222. net.dwDisplayType = 0;
  1223. net.dwUsage = 0;
  1224. net.lpLocalName = pszLocalName;
  1225. net.lpRemoteName = pszRemoteName;
  1226. net.lpComment = NULL;
  1227. net.lpProvider = pszProviderName;
  1228. NETCONNECTINFOSTRUCT inf;
  1229. inf.cbStructure = sizeof(inf);
  1230. DWORD bufSizeIn = inf.cbStructure;
  1231. // clear it
  1232. SetDlgItemText(hwnd, IDC_RETURNFLAGS, TEXT(""));
  1233. SetDlgItemText(hwnd, IDC_RETURNSPEED, TEXT(""));
  1234. SetDlgItemText(hwnd, IDC_RETURNDELAY, TEXT(""));
  1235. SetDlgItemText(hwnd, IDC_RETURNOPTDATASIZE, TEXT(""));
  1236. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  1237. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  1238. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1239. DWORD dw = MultinetGetConnectionPerformance(
  1240. &net,
  1241. &inf);
  1242. SetCursor(hOldCursor);
  1243. DoError(hwnd, dw);
  1244. if (WN_SUCCESS == dw)
  1245. {
  1246. TCHAR szBuf[MAX_PATH];
  1247. wsprintf(szBuf, TEXT("%#lx"), inf.dwFlags);
  1248. SetDlgItemText(hwnd, IDC_RETURNFLAGS, szBuf);
  1249. SetDlgItemInt (hwnd, IDC_RETURNSPEED, inf.dwSpeed, FALSE);
  1250. SetDlgItemInt (hwnd, IDC_RETURNDELAY, inf.dwDelay, FALSE);
  1251. SetDlgItemInt (hwnd, IDC_RETURNOPTDATASIZE,
  1252. inf.dwOptDataSize, FALSE);
  1253. }
  1254. SetDlgItemInt(hwnd, IDC_BUFSIZEIN, bufSizeIn, FALSE);
  1255. SetDlgItemInt(hwnd, IDC_BUFSIZE, inf.cbStructure, FALSE);
  1256. return TRUE;
  1257. }
  1258. case IDOK:
  1259. EndDialog(hwnd, TRUE);
  1260. return TRUE;
  1261. case IDC_LOCAL:
  1262. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT),
  1263. (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL)));
  1264. return TRUE;
  1265. case IDC_REMOTE:
  1266. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT),
  1267. (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE)));
  1268. return TRUE;
  1269. case IDC_PROVIDER:
  1270. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT),
  1271. (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER)));
  1272. return TRUE;
  1273. } // end switch (LOWORD(wParam))
  1274. return FALSE;
  1275. }
  1276. default:
  1277. return FALSE; // didn't process
  1278. }
  1279. }
  1280. INT_PTR CALLBACK
  1281. FormatNetworkNameDlgProc(
  1282. IN HWND hwnd,
  1283. IN UINT uMsg,
  1284. IN WPARAM wParam,
  1285. IN LPARAM lParam
  1286. )
  1287. {
  1288. switch (uMsg)
  1289. {
  1290. case WM_INITDIALOG:
  1291. PlaceIt(hwnd);
  1292. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1293. SetDlgItemText(hwnd, IDC_RETURN, TEXT(""));
  1294. SetDlgItemText(hwnd, IDC_REMOTE_TEXT, TEXT(""));
  1295. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT), FALSE);
  1296. CheckDlgButton(hwnd, IDC_REMOTE_TEXT, 0);
  1297. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  1298. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT), FALSE);
  1299. CheckDlgButton(hwnd, IDC_PROVIDER_TEXT, 0);
  1300. return 1; // didn't call SetFocus
  1301. case WM_COMMAND:
  1302. {
  1303. switch (LOWORD(wParam))
  1304. {
  1305. case IDC_GO:
  1306. {
  1307. // get the flags
  1308. DWORD dwFlags = 0;
  1309. if (1 == IsDlgButtonChecked(hwnd, IDC_MULTILINE))
  1310. {
  1311. dwFlags |= WNFMT_MULTILINE;
  1312. }
  1313. if (1 == IsDlgButtonChecked(hwnd, IDC_ABBREVIATED))
  1314. {
  1315. dwFlags |= WNFMT_ABBREVIATED;
  1316. }
  1317. if (1 == IsDlgButtonChecked(hwnd, IDC_INENUM))
  1318. {
  1319. dwFlags |= WNFMT_INENUM;
  1320. }
  1321. TCHAR szRemoteName[200];
  1322. LPTSTR pszRemoteName = NULL;
  1323. if (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE))
  1324. {
  1325. GetDlgItemText(hwnd, IDC_REMOTE_TEXT, szRemoteName, ARRAYLEN(szRemoteName));
  1326. pszRemoteName = szRemoteName;
  1327. }
  1328. TCHAR szProviderName[200];
  1329. LPTSTR pszProviderName = NULL;
  1330. if (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER))
  1331. {
  1332. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderName, ARRAYLEN(szProviderName));
  1333. pszProviderName = szProviderName;
  1334. }
  1335. TCHAR szBuf[1024];
  1336. szBuf[0] = TEXT('\0');
  1337. DWORD nLength = ARRAYLEN(szBuf);
  1338. DWORD dwAveCharPerLine = 100000; // BUGBUG
  1339. // clear it
  1340. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1341. SetDlgItemText(hwnd, IDC_RETURN, TEXT(""));
  1342. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1343. DWORD dw = WNetFormatNetworkName(
  1344. pszProviderName,
  1345. pszRemoteName,
  1346. szBuf,
  1347. &nLength,
  1348. dwFlags,
  1349. dwAveCharPerLine);
  1350. SetCursor(hOldCursor);
  1351. SetDlgItemText(hwnd, IDC_RETURN, szBuf);
  1352. DoError(hwnd, dw);
  1353. return TRUE;
  1354. }
  1355. case IDOK:
  1356. EndDialog(hwnd, TRUE);
  1357. return TRUE;
  1358. case IDC_REMOTE:
  1359. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT),
  1360. (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE)));
  1361. return TRUE;
  1362. case IDC_PROVIDER:
  1363. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT),
  1364. (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER)));
  1365. return TRUE;
  1366. } // end switch (LOWORD(wParam))
  1367. return FALSE;
  1368. }
  1369. default:
  1370. return FALSE; // didn't process
  1371. }
  1372. }
  1373. INT_PTR CALLBACK
  1374. GetProviderTypeDlgProc(
  1375. IN HWND hwnd,
  1376. IN UINT uMsg,
  1377. IN WPARAM wParam,
  1378. IN LPARAM lParam
  1379. )
  1380. {
  1381. switch (uMsg)
  1382. {
  1383. case WM_INITDIALOG:
  1384. PlaceIt(hwnd);
  1385. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1386. SetDlgItemText(hwnd, IDC_PROVIDERTYPE, TEXT(""));
  1387. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  1388. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT), FALSE);
  1389. CheckDlgButton(hwnd, IDC_PROVIDER_TEXT, 0);
  1390. return 1; // didn't call SetFocus
  1391. case WM_COMMAND:
  1392. {
  1393. switch (LOWORD(wParam))
  1394. {
  1395. case IDC_GO:
  1396. {
  1397. TCHAR szProviderName[200];
  1398. LPTSTR pszProviderName = NULL;
  1399. if (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER))
  1400. {
  1401. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderName, ARRAYLEN(szProviderName));
  1402. pszProviderName = szProviderName;
  1403. }
  1404. // clear it
  1405. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1406. SetDlgItemText(hwnd, IDC_PROVIDERTYPE, TEXT(""));
  1407. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1408. DWORD dwNetType;
  1409. DWORD dw = LoadMpr();
  1410. if (dw == WN_SUCCESS)
  1411. {
  1412. if (NULL == pfnWNetGetProviderType)
  1413. {
  1414. dw = ERROR_PROC_NOT_FOUND;
  1415. }
  1416. else
  1417. {
  1418. dw = (*pfnWNetGetProviderType)(pszProviderName, &dwNetType);
  1419. }
  1420. }
  1421. SetCursor(hOldCursor);
  1422. if (WN_SUCCESS == dw)
  1423. {
  1424. TCHAR sz[100];
  1425. wsprintf(sz, TEXT("0x%08x"), dwNetType);
  1426. SetDlgItemText(hwnd, IDC_PROVIDERTYPE, sz);
  1427. }
  1428. DoError(hwnd, dw);
  1429. return TRUE;
  1430. }
  1431. case IDOK:
  1432. EndDialog(hwnd, TRUE);
  1433. return TRUE;
  1434. case IDC_PROVIDER:
  1435. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT),
  1436. (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER)));
  1437. return TRUE;
  1438. } // end switch (LOWORD(wParam))
  1439. return FALSE;
  1440. }
  1441. default:
  1442. return FALSE; // didn't process
  1443. }
  1444. }
  1445. INT_PTR CALLBACK
  1446. GetProviderNameDlgProc(
  1447. IN HWND hwnd,
  1448. IN UINT uMsg,
  1449. IN WPARAM wParam,
  1450. IN LPARAM lParam
  1451. )
  1452. {
  1453. switch (uMsg)
  1454. {
  1455. case WM_INITDIALOG:
  1456. PlaceIt(hwnd);
  1457. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1458. SetDlgItemText(hwnd, IDC_PROVIDERNAME, TEXT(""));
  1459. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  1460. return 1; // didn't call SetFocus
  1461. case WM_COMMAND:
  1462. {
  1463. switch (LOWORD(wParam))
  1464. {
  1465. case IDC_GO:
  1466. {
  1467. DWORD dwNetType;
  1468. TCHAR szProviderType[200];
  1469. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderType, ARRAYLEN(szProviderType));
  1470. _stscanf(szProviderType, TEXT("%lx"), &dwNetType);
  1471. // clear it
  1472. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1473. SetDlgItemText(hwnd, IDC_PROVIDERNAME, TEXT(""));
  1474. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1475. TCHAR szProviderName[MAX_PATH];
  1476. DWORD cchProviderName = ARRAYLEN(szProviderName);
  1477. DWORD dw = WNetGetProviderName(dwNetType, szProviderName, &cchProviderName);
  1478. SetCursor(hOldCursor);
  1479. if (WN_SUCCESS == dw)
  1480. {
  1481. TCHAR sz[100];
  1482. SetDlgItemText(hwnd, IDC_PROVIDERNAME, szProviderName);
  1483. }
  1484. DoError(hwnd, dw);
  1485. return TRUE;
  1486. }
  1487. case IDOK:
  1488. EndDialog(hwnd, TRUE);
  1489. return TRUE;
  1490. } // end switch (LOWORD(wParam))
  1491. return FALSE;
  1492. }
  1493. default:
  1494. return FALSE; // didn't process
  1495. }
  1496. }
  1497. INT_PTR CALLBACK
  1498. GetNetworkInformationDlgProc(
  1499. IN HWND hwnd,
  1500. IN UINT uMsg,
  1501. IN WPARAM wParam,
  1502. IN LPARAM lParam
  1503. )
  1504. {
  1505. switch (uMsg)
  1506. {
  1507. case WM_INITDIALOG:
  1508. PlaceIt(hwnd);
  1509. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1510. SetDlgItemText(hwnd, IDC_PROVIDERVERSION, TEXT(""));
  1511. SetDlgItemText(hwnd, IDC_STATUS, TEXT(""));
  1512. SetDlgItemText(hwnd, IDC_CHARACTERISTICS, TEXT(""));
  1513. SetDlgItemText(hwnd, IDC_HANDLE, TEXT(""));
  1514. SetDlgItemText(hwnd, IDC_NETTYPE, TEXT(""));
  1515. SetDlgItemText(hwnd, IDC_PRINTERS, TEXT(""));
  1516. SetDlgItemText(hwnd, IDC_DRIVES, TEXT(""));
  1517. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  1518. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT), FALSE);
  1519. CheckDlgButton(hwnd, IDC_PROVIDER_TEXT, 0);
  1520. return 1; // didn't call SetFocus
  1521. case WM_COMMAND:
  1522. {
  1523. switch (LOWORD(wParam))
  1524. {
  1525. case IDC_GO:
  1526. {
  1527. TCHAR szProviderName[200];
  1528. LPTSTR pszProviderName = NULL;
  1529. if (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER))
  1530. {
  1531. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderName, ARRAYLEN(szProviderName));
  1532. pszProviderName = szProviderName;
  1533. }
  1534. NETINFOSTRUCT ni;
  1535. ni.cbStructure = sizeof(NETINFOSTRUCT);
  1536. // clear it
  1537. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1538. SetDlgItemText(hwnd, IDC_PROVIDERVERSION, TEXT(""));
  1539. SetDlgItemText(hwnd, IDC_STATUS, TEXT(""));
  1540. SetDlgItemText(hwnd, IDC_CHARACTERISTICS, TEXT(""));
  1541. SetDlgItemText(hwnd, IDC_HANDLE, TEXT(""));
  1542. SetDlgItemText(hwnd, IDC_NETTYPE, TEXT(""));
  1543. SetDlgItemText(hwnd, IDC_PRINTERS, TEXT(""));
  1544. SetDlgItemText(hwnd, IDC_DRIVES, TEXT(""));
  1545. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1546. DWORD dw = WNetGetNetworkInformation(pszProviderName, &ni);
  1547. SetCursor(hOldCursor);
  1548. if (WN_SUCCESS == dw)
  1549. {
  1550. TCHAR sz[100];
  1551. wsprintf(sz, TEXT("0x%08lx"), ni.dwProviderVersion);
  1552. SetDlgItemText(hwnd, IDC_PROVIDERVERSION, sz);
  1553. wsprintf(sz, TEXT("0x%08lx"), ni.dwStatus);
  1554. SetDlgItemText(hwnd, IDC_STATUS, sz);
  1555. wsprintf(sz, TEXT("0x%08lx"), ni.dwCharacteristics);
  1556. SetDlgItemText(hwnd, IDC_CHARACTERISTICS, sz);
  1557. wsprintf(sz, TEXT("0x%08lx"), ni.dwHandle);
  1558. SetDlgItemText(hwnd, IDC_HANDLE, sz);
  1559. wsprintf(sz, TEXT("0x%04x"), ni.wNetType);
  1560. SetDlgItemText(hwnd, IDC_NETTYPE, sz);
  1561. wsprintf(sz, TEXT("0x%08lx"), ni.dwPrinters);
  1562. SetDlgItemText(hwnd, IDC_PRINTERS, sz);
  1563. wsprintf(sz, TEXT("0x%08lx"), ni.dwDrives);
  1564. SetDlgItemText(hwnd, IDC_DRIVES, sz);
  1565. }
  1566. DoError(hwnd, dw);
  1567. return TRUE;
  1568. }
  1569. case IDOK:
  1570. EndDialog(hwnd, TRUE);
  1571. return TRUE;
  1572. case IDC_PROVIDER:
  1573. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT),
  1574. (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER)));
  1575. return TRUE;
  1576. } // end switch (LOWORD(wParam))
  1577. return FALSE;
  1578. }
  1579. default:
  1580. return FALSE; // didn't process
  1581. }
  1582. }
  1583. INT_PTR CALLBACK
  1584. CancelConnectionDlgProc(
  1585. IN HWND hwnd,
  1586. IN UINT uMsg,
  1587. IN WPARAM wParam,
  1588. IN LPARAM lParam
  1589. )
  1590. {
  1591. switch (uMsg)
  1592. {
  1593. case WM_INITDIALOG:
  1594. PlaceIt(hwnd);
  1595. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1596. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  1597. CheckRadioButton(hwnd, IDC_FORCE, IDC_NOFORCE, IDC_NOFORCE);
  1598. return 1; // didn't call SetFocus
  1599. case WM_COMMAND:
  1600. {
  1601. switch (LOWORD(wParam))
  1602. {
  1603. case IDC_GO:
  1604. {
  1605. BOOL fForce = FALSE;
  1606. if (1 == IsDlgButtonChecked(hwnd, IDC_FORCE))
  1607. {
  1608. fForce = TRUE;
  1609. }
  1610. else if (1 == IsDlgButtonChecked(hwnd, IDC_NOFORCE))
  1611. {
  1612. fForce = FALSE;
  1613. }
  1614. else
  1615. {
  1616. // internal error
  1617. }
  1618. TCHAR szLocalName[200];
  1619. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  1620. // clear it
  1621. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1622. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1623. DWORD dw = WNetCancelConnection(szLocalName, fForce);
  1624. SetCursor(hOldCursor);
  1625. DoError(hwnd, dw);
  1626. return TRUE;
  1627. }
  1628. case IDOK:
  1629. EndDialog(hwnd, TRUE);
  1630. return TRUE;
  1631. }
  1632. return FALSE;
  1633. }
  1634. default:
  1635. return FALSE; // didn't process
  1636. }
  1637. }
  1638. INT_PTR CALLBACK
  1639. CancelConnection2DlgProc(
  1640. IN HWND hwnd,
  1641. IN UINT uMsg,
  1642. IN WPARAM wParam,
  1643. IN LPARAM lParam
  1644. )
  1645. {
  1646. switch (uMsg)
  1647. {
  1648. case WM_INITDIALOG:
  1649. PlaceIt(hwnd);
  1650. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1651. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  1652. CheckRadioButton(hwnd, IDC_FORCE, IDC_NOFORCE, IDC_NOFORCE);
  1653. CheckDlgButton(hwnd, IDC_UPDATE_PROFILE, 0);
  1654. CheckDlgButton(hwnd, IDC_REFCOUNT, 0);
  1655. return 1; // didn't call SetFocus
  1656. case WM_COMMAND:
  1657. {
  1658. switch (LOWORD(wParam))
  1659. {
  1660. case IDC_GO:
  1661. {
  1662. // get the flags
  1663. DWORD dwFlags = 0;
  1664. if (1 == IsDlgButtonChecked(hwnd, IDC_UPDATE_PROFILE))
  1665. {
  1666. dwFlags |= CONNECT_UPDATE_PROFILE;
  1667. }
  1668. if (1 == IsDlgButtonChecked(hwnd, IDC_REFCOUNT))
  1669. {
  1670. dwFlags |= CONNECT_REFCOUNT;
  1671. }
  1672. BOOL fForce = FALSE;
  1673. if (1 == IsDlgButtonChecked(hwnd, IDC_FORCE))
  1674. {
  1675. fForce = TRUE;
  1676. }
  1677. else if (1 == IsDlgButtonChecked(hwnd, IDC_NOFORCE))
  1678. {
  1679. fForce = FALSE;
  1680. }
  1681. else
  1682. {
  1683. // internal error
  1684. }
  1685. TCHAR szLocalName[200];
  1686. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  1687. // clear it
  1688. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1689. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1690. DWORD dw = WNetCancelConnection2(szLocalName, dwFlags, fForce);
  1691. SetCursor(hOldCursor);
  1692. DoError(hwnd, dw);
  1693. return TRUE;
  1694. }
  1695. case IDOK:
  1696. EndDialog(hwnd, TRUE);
  1697. return TRUE;
  1698. }
  1699. return FALSE;
  1700. }
  1701. default:
  1702. return FALSE; // didn't process
  1703. }
  1704. }
  1705. INT_PTR CALLBACK
  1706. AddConnectionDlgProc(
  1707. IN HWND hwnd,
  1708. IN UINT uMsg,
  1709. IN WPARAM wParam,
  1710. IN LPARAM lParam
  1711. )
  1712. {
  1713. switch (uMsg)
  1714. {
  1715. case WM_INITDIALOG:
  1716. PlaceIt(hwnd);
  1717. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1718. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  1719. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT), FALSE);
  1720. CheckDlgButton(hwnd, IDC_LOCAL_TEXT, 0);
  1721. SetDlgItemText(hwnd, IDC_REMOTE_TEXT, TEXT(""));
  1722. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT), FALSE);
  1723. CheckDlgButton(hwnd, IDC_REMOTE_TEXT, 0);
  1724. SetDlgItemText(hwnd, IDC_PASSWORD_TEXT, TEXT(""));
  1725. EnableWindow(GetDlgItem(hwnd, IDC_PASSWORD_TEXT), FALSE);
  1726. CheckDlgButton(hwnd, IDC_PASSWORD_TEXT, 0);
  1727. return 1; // didn't call SetFocus
  1728. case WM_COMMAND:
  1729. {
  1730. switch (LOWORD(wParam))
  1731. {
  1732. case IDC_GO:
  1733. {
  1734. TCHAR szLocalName[200];
  1735. LPTSTR pszLocalName = NULL;
  1736. if (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL))
  1737. {
  1738. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  1739. pszLocalName = szLocalName;
  1740. }
  1741. TCHAR szRemoteName[200];
  1742. LPTSTR pszRemoteName = NULL;
  1743. if (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE))
  1744. {
  1745. GetDlgItemText(hwnd, IDC_REMOTE_TEXT, szRemoteName, ARRAYLEN(szRemoteName));
  1746. pszRemoteName = szRemoteName;
  1747. }
  1748. TCHAR szPassword[200];
  1749. LPTSTR pszPassword = NULL;
  1750. if (1 == IsDlgButtonChecked(hwnd, IDC_PASSWORD))
  1751. {
  1752. GetDlgItemText(hwnd, IDC_PASSWORD_TEXT, szPassword, ARRAYLEN(szPassword));
  1753. pszPassword = szPassword;
  1754. }
  1755. // clear it
  1756. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1757. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1758. DWORD dw = WNetAddConnection(
  1759. pszRemoteName,
  1760. pszPassword,
  1761. pszLocalName);
  1762. SetCursor(hOldCursor);
  1763. DoError(hwnd, dw);
  1764. return TRUE;
  1765. }
  1766. case IDOK:
  1767. EndDialog(hwnd, TRUE);
  1768. return TRUE;
  1769. case IDC_LOCAL:
  1770. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT),
  1771. (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL)));
  1772. return TRUE;
  1773. case IDC_REMOTE:
  1774. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT),
  1775. (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE)));
  1776. return TRUE;
  1777. case IDC_PASSWORD:
  1778. EnableWindow(GetDlgItem(hwnd, IDC_PASSWORD_TEXT),
  1779. (1 == IsDlgButtonChecked(hwnd, IDC_PASSWORD)));
  1780. return TRUE;
  1781. } // end switch (LOWORD(wParam))
  1782. return FALSE;
  1783. }
  1784. default:
  1785. return FALSE; // didn't process
  1786. }
  1787. }
  1788. INT_PTR CALLBACK
  1789. AddConnection2DlgProc(
  1790. IN HWND hwnd,
  1791. IN UINT uMsg,
  1792. IN WPARAM wParam,
  1793. IN LPARAM lParam
  1794. )
  1795. {
  1796. switch (uMsg)
  1797. {
  1798. case WM_INITDIALOG:
  1799. PlaceIt(hwnd);
  1800. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1801. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  1802. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT), FALSE);
  1803. CheckDlgButton(hwnd, IDC_LOCAL_TEXT, 0);
  1804. SetDlgItemText(hwnd, IDC_REMOTE_TEXT, TEXT(""));
  1805. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT), FALSE);
  1806. CheckDlgButton(hwnd, IDC_REMOTE_TEXT, 0);
  1807. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  1808. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT), FALSE);
  1809. CheckDlgButton(hwnd, IDC_PROVIDER_TEXT, 0);
  1810. SetDlgItemText(hwnd, IDC_PASSWORD_TEXT, TEXT(""));
  1811. EnableWindow(GetDlgItem(hwnd, IDC_PASSWORD_TEXT), FALSE);
  1812. CheckDlgButton(hwnd, IDC_PASSWORD_TEXT, 0);
  1813. SetDlgItemText(hwnd, IDC_USER_TEXT, TEXT(""));
  1814. EnableWindow(GetDlgItem(hwnd, IDC_USER_TEXT), FALSE);
  1815. CheckDlgButton(hwnd, IDC_USER_TEXT, 0);
  1816. CheckRadioButton(hwnd, IDC_DISK, IDC_PRINTER, IDC_DISK);
  1817. return 1; // didn't call SetFocus
  1818. case WM_COMMAND:
  1819. {
  1820. switch (LOWORD(wParam))
  1821. {
  1822. case IDC_GO:
  1823. {
  1824. // get the flags
  1825. DWORD dwFlags = 0;
  1826. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_UPDATE_PROFILE))
  1827. {
  1828. dwFlags |= CONNECT_UPDATE_PROFILE;
  1829. }
  1830. DWORD dwType = 0;
  1831. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  1832. {
  1833. dwType = RESOURCETYPE_DISK;
  1834. }
  1835. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  1836. {
  1837. dwType = RESOURCETYPE_PRINT;
  1838. }
  1839. else
  1840. {
  1841. // internal error
  1842. }
  1843. TCHAR szLocalName[200];
  1844. LPTSTR pszLocalName = NULL;
  1845. if (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL))
  1846. {
  1847. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  1848. pszLocalName = szLocalName;
  1849. }
  1850. TCHAR szRemoteName[200];
  1851. LPTSTR pszRemoteName = NULL;
  1852. if (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE))
  1853. {
  1854. GetDlgItemText(hwnd, IDC_REMOTE_TEXT, szRemoteName, ARRAYLEN(szRemoteName));
  1855. pszRemoteName = szRemoteName;
  1856. }
  1857. TCHAR szProviderName[200];
  1858. LPTSTR pszProviderName = NULL;
  1859. if (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER))
  1860. {
  1861. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderName, ARRAYLEN(szProviderName));
  1862. pszProviderName = szProviderName;
  1863. }
  1864. TCHAR szPassword[200];
  1865. LPTSTR pszPassword = NULL;
  1866. if (1 == IsDlgButtonChecked(hwnd, IDC_PASSWORD))
  1867. {
  1868. GetDlgItemText(hwnd, IDC_PASSWORD_TEXT, szPassword, ARRAYLEN(szPassword));
  1869. pszPassword = szPassword;
  1870. }
  1871. TCHAR szUserName[200];
  1872. LPTSTR pszUserName = NULL;
  1873. if (1 == IsDlgButtonChecked(hwnd, IDC_USER))
  1874. {
  1875. GetDlgItemText(hwnd, IDC_USER_TEXT, szUserName, ARRAYLEN(szUserName));
  1876. pszUserName = szUserName;
  1877. }
  1878. NETRESOURCE net;
  1879. net.dwScope = 0;
  1880. net.dwType = dwType;
  1881. net.dwDisplayType = 0;
  1882. net.dwUsage = 0;
  1883. net.lpLocalName = pszLocalName;
  1884. net.lpRemoteName = pszRemoteName;
  1885. net.lpComment = NULL;
  1886. net.lpProvider = pszProviderName;
  1887. // clear it
  1888. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1889. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  1890. DWORD dw = WNetAddConnection2(
  1891. &net,
  1892. pszPassword,
  1893. pszUserName,
  1894. dwFlags);
  1895. SetCursor(hOldCursor);
  1896. DoError(hwnd, dw);
  1897. return TRUE;
  1898. }
  1899. case IDOK:
  1900. EndDialog(hwnd, TRUE);
  1901. return TRUE;
  1902. case IDC_LOCAL:
  1903. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT),
  1904. (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL)));
  1905. return TRUE;
  1906. case IDC_REMOTE:
  1907. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT),
  1908. (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE)));
  1909. return TRUE;
  1910. case IDC_PROVIDER:
  1911. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT),
  1912. (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER)));
  1913. return TRUE;
  1914. case IDC_PASSWORD:
  1915. EnableWindow(GetDlgItem(hwnd, IDC_PASSWORD_TEXT),
  1916. (1 == IsDlgButtonChecked(hwnd, IDC_PASSWORD)));
  1917. return TRUE;
  1918. case IDC_USER:
  1919. EnableWindow(GetDlgItem(hwnd, IDC_USER_TEXT),
  1920. (1 == IsDlgButtonChecked(hwnd, IDC_USER)));
  1921. return TRUE;
  1922. } // end switch (LOWORD(wParam))
  1923. return FALSE;
  1924. }
  1925. default:
  1926. return FALSE; // didn't process
  1927. }
  1928. }
  1929. INT_PTR CALLBACK
  1930. AddConnection3DlgProc(
  1931. IN HWND hwnd,
  1932. IN UINT uMsg,
  1933. IN WPARAM wParam,
  1934. IN LPARAM lParam
  1935. )
  1936. {
  1937. switch (uMsg)
  1938. {
  1939. case WM_INITDIALOG:
  1940. PlaceIt(hwnd);
  1941. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  1942. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  1943. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT), FALSE);
  1944. CheckDlgButton(hwnd, IDC_LOCAL_TEXT, 0);
  1945. SetDlgItemText(hwnd, IDC_REMOTE_TEXT, TEXT(""));
  1946. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT), FALSE);
  1947. CheckDlgButton(hwnd, IDC_REMOTE_TEXT, 0);
  1948. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  1949. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT), FALSE);
  1950. CheckDlgButton(hwnd, IDC_PROVIDER_TEXT, 0);
  1951. SetDlgItemText(hwnd, IDC_PASSWORD_TEXT, TEXT(""));
  1952. EnableWindow(GetDlgItem(hwnd, IDC_PASSWORD_TEXT), FALSE);
  1953. CheckDlgButton(hwnd, IDC_PASSWORD_TEXT, 0);
  1954. SetDlgItemText(hwnd, IDC_USER_TEXT, TEXT(""));
  1955. EnableWindow(GetDlgItem(hwnd, IDC_USER_TEXT), FALSE);
  1956. CheckDlgButton(hwnd, IDC_USER_TEXT, 0);
  1957. CheckRadioButton(hwnd, IDC_HWND_VALID, IDC_HWND_NO, IDC_HWND_VALID);
  1958. CheckRadioButton(hwnd, IDC_DISK, IDC_PRINTER, IDC_DISK);
  1959. return 1; // didn't call SetFocus
  1960. case WM_COMMAND:
  1961. {
  1962. switch (LOWORD(wParam))
  1963. {
  1964. case IDC_GO:
  1965. {
  1966. // get the flags
  1967. DWORD dwFlags = 0;
  1968. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_TEMPORARY))
  1969. {
  1970. dwFlags |= CONNECT_TEMPORARY;
  1971. }
  1972. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_INTERACTIVE))
  1973. {
  1974. dwFlags |= CONNECT_INTERACTIVE;
  1975. }
  1976. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_PROMPT))
  1977. {
  1978. dwFlags |= CONNECT_PROMPT;
  1979. }
  1980. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_UPDATE_PROFILE))
  1981. {
  1982. dwFlags |= CONNECT_UPDATE_PROFILE;
  1983. }
  1984. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_UPDATE_RECENT))
  1985. {
  1986. dwFlags |= CONNECT_UPDATE_RECENT;
  1987. }
  1988. HWND hwndParent = NULL;
  1989. if (1 == IsDlgButtonChecked(hwnd, IDC_HWND_VALID))
  1990. {
  1991. hwndParent = hwnd;
  1992. }
  1993. DWORD dwType = 0;
  1994. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  1995. {
  1996. dwType = RESOURCETYPE_DISK;
  1997. }
  1998. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  1999. {
  2000. dwType = RESOURCETYPE_PRINT;
  2001. }
  2002. else
  2003. {
  2004. // internal error
  2005. }
  2006. TCHAR szLocalName[200];
  2007. LPTSTR pszLocalName = NULL;
  2008. if (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL))
  2009. {
  2010. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  2011. pszLocalName = szLocalName;
  2012. }
  2013. TCHAR szRemoteName[200];
  2014. LPTSTR pszRemoteName = NULL;
  2015. if (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE))
  2016. {
  2017. GetDlgItemText(hwnd, IDC_REMOTE_TEXT, szRemoteName, ARRAYLEN(szRemoteName));
  2018. pszRemoteName = szRemoteName;
  2019. }
  2020. TCHAR szProviderName[200];
  2021. LPTSTR pszProviderName = NULL;
  2022. if (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER))
  2023. {
  2024. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderName, ARRAYLEN(szProviderName));
  2025. pszProviderName = szProviderName;
  2026. }
  2027. TCHAR szPassword[200];
  2028. LPTSTR pszPassword = NULL;
  2029. if (1 == IsDlgButtonChecked(hwnd, IDC_PASSWORD))
  2030. {
  2031. GetDlgItemText(hwnd, IDC_PASSWORD_TEXT, szPassword, ARRAYLEN(szPassword));
  2032. pszPassword = szPassword;
  2033. }
  2034. TCHAR szUserName[200];
  2035. LPTSTR pszUserName = NULL;
  2036. if (1 == IsDlgButtonChecked(hwnd, IDC_USER))
  2037. {
  2038. GetDlgItemText(hwnd, IDC_USER_TEXT, szUserName, ARRAYLEN(szUserName));
  2039. pszUserName = szUserName;
  2040. }
  2041. NETRESOURCE net;
  2042. net.dwScope = 0;
  2043. net.dwType = dwType;
  2044. net.dwDisplayType = 0;
  2045. net.dwUsage = 0;
  2046. net.lpLocalName = pszLocalName;
  2047. net.lpRemoteName = pszRemoteName;
  2048. net.lpComment = NULL;
  2049. net.lpProvider = pszProviderName;
  2050. // clear it
  2051. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  2052. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  2053. DWORD dw = WNetAddConnection3(
  2054. hwndParent,
  2055. &net,
  2056. pszPassword,
  2057. pszUserName,
  2058. dwFlags);
  2059. SetCursor(hOldCursor);
  2060. DoError(hwnd, dw);
  2061. return TRUE;
  2062. }
  2063. case IDOK:
  2064. EndDialog(hwnd, TRUE);
  2065. return TRUE;
  2066. case IDC_LOCAL:
  2067. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT),
  2068. (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL)));
  2069. return TRUE;
  2070. case IDC_REMOTE:
  2071. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT),
  2072. (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE)));
  2073. return TRUE;
  2074. case IDC_PROVIDER:
  2075. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT),
  2076. (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER)));
  2077. return TRUE;
  2078. case IDC_PASSWORD:
  2079. EnableWindow(GetDlgItem(hwnd, IDC_PASSWORD_TEXT),
  2080. (1 == IsDlgButtonChecked(hwnd, IDC_PASSWORD)));
  2081. return TRUE;
  2082. case IDC_USER:
  2083. EnableWindow(GetDlgItem(hwnd, IDC_USER_TEXT),
  2084. (1 == IsDlgButtonChecked(hwnd, IDC_USER)));
  2085. return TRUE;
  2086. } // end switch (LOWORD(wParam))
  2087. return FALSE;
  2088. }
  2089. default:
  2090. return FALSE; // didn't process
  2091. }
  2092. }
  2093. INT_PTR CALLBACK
  2094. UseConnectionDlgProc(
  2095. IN HWND hwnd,
  2096. IN UINT uMsg,
  2097. IN WPARAM wParam,
  2098. IN LPARAM lParam
  2099. )
  2100. {
  2101. switch (uMsg)
  2102. {
  2103. case WM_INITDIALOG:
  2104. PlaceIt(hwnd);
  2105. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  2106. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  2107. SetDlgItemText(hwnd, IDC_ACCESSNAME, TEXT(""));
  2108. SetDlgItemText(hwnd, IDC_RESULT, TEXT(""));
  2109. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  2110. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT), FALSE);
  2111. CheckDlgButton(hwnd, IDC_LOCAL_TEXT, 0);
  2112. SetDlgItemText(hwnd, IDC_REMOTE_TEXT, TEXT(""));
  2113. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT), FALSE);
  2114. CheckDlgButton(hwnd, IDC_REMOTE_TEXT, 0);
  2115. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  2116. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT), FALSE);
  2117. CheckDlgButton(hwnd, IDC_PROVIDER_TEXT, 0);
  2118. SetDlgItemText(hwnd, IDC_PASSWORD_TEXT, TEXT(""));
  2119. EnableWindow(GetDlgItem(hwnd, IDC_PASSWORD_TEXT), FALSE);
  2120. CheckDlgButton(hwnd, IDC_PASSWORD_TEXT, 0);
  2121. SetDlgItemText(hwnd, IDC_USER_TEXT, TEXT(""));
  2122. EnableWindow(GetDlgItem(hwnd, IDC_USER_TEXT), FALSE);
  2123. CheckDlgButton(hwnd, IDC_USER_TEXT, 0);
  2124. CheckRadioButton(hwnd, IDC_HWND_VALID, IDC_HWND_NO, IDC_HWND_VALID);
  2125. CheckRadioButton(hwnd, IDC_DISK, IDC_PRINTER, IDC_DISK);
  2126. CheckRadioButton(hwnd, IDC_ACCESS_YES, IDC_ACCESS_NO, IDC_ACCESS_YES);
  2127. return 1; // didn't call SetFocus
  2128. case WM_COMMAND:
  2129. {
  2130. switch (LOWORD(wParam))
  2131. {
  2132. case IDC_GO:
  2133. {
  2134. // get the flags
  2135. DWORD dwFlags = 0;
  2136. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_TEMPORARY))
  2137. {
  2138. dwFlags |= CONNECT_TEMPORARY;
  2139. }
  2140. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_INTERACTIVE))
  2141. {
  2142. dwFlags |= CONNECT_INTERACTIVE;
  2143. }
  2144. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_PROMPT))
  2145. {
  2146. dwFlags |= CONNECT_PROMPT;
  2147. }
  2148. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_UPDATE_PROFILE))
  2149. {
  2150. dwFlags |= CONNECT_UPDATE_PROFILE;
  2151. }
  2152. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_UPDATE_RECENT))
  2153. {
  2154. dwFlags |= CONNECT_UPDATE_RECENT;
  2155. }
  2156. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_REDIRECT))
  2157. {
  2158. dwFlags |= CONNECT_REDIRECT;
  2159. }
  2160. if (1 == IsDlgButtonChecked(hwnd, IDC_CONNECT_CURRENT_MEDIA))
  2161. {
  2162. dwFlags |= CONNECT_CURRENT_MEDIA;
  2163. }
  2164. HWND hwndParent = NULL;
  2165. if (1 == IsDlgButtonChecked(hwnd, IDC_HWND_VALID))
  2166. {
  2167. hwndParent = hwnd;
  2168. }
  2169. DWORD dwType = 0;
  2170. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  2171. {
  2172. dwType = RESOURCETYPE_DISK;
  2173. }
  2174. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  2175. {
  2176. dwType = RESOURCETYPE_PRINT;
  2177. }
  2178. else
  2179. {
  2180. // internal error
  2181. }
  2182. DWORD dwBufferSize = 0;
  2183. TCHAR szAccessName[MAX_PATH];
  2184. szAccessName[0] = TEXT('\0');
  2185. LPTSTR pszAccessName = NULL;
  2186. if (1 == IsDlgButtonChecked(hwnd, IDC_ACCESS_YES))
  2187. {
  2188. pszAccessName = szAccessName;
  2189. dwBufferSize = ARRAYLEN(szAccessName);
  2190. }
  2191. TCHAR szLocalName[200];
  2192. LPTSTR pszLocalName = NULL;
  2193. if (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL))
  2194. {
  2195. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  2196. pszLocalName = szLocalName;
  2197. }
  2198. TCHAR szRemoteName[200];
  2199. LPTSTR pszRemoteName = NULL;
  2200. if (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE))
  2201. {
  2202. GetDlgItemText(hwnd, IDC_REMOTE_TEXT, szRemoteName, ARRAYLEN(szRemoteName));
  2203. pszRemoteName = szRemoteName;
  2204. }
  2205. TCHAR szProviderName[200];
  2206. LPTSTR pszProviderName = NULL;
  2207. if (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER))
  2208. {
  2209. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderName, ARRAYLEN(szProviderName));
  2210. pszProviderName = szProviderName;
  2211. }
  2212. TCHAR szPassword[200];
  2213. LPTSTR pszPassword = NULL;
  2214. if (1 == IsDlgButtonChecked(hwnd, IDC_PASSWORD))
  2215. {
  2216. GetDlgItemText(hwnd, IDC_PASSWORD_TEXT, szPassword, ARRAYLEN(szPassword));
  2217. pszPassword = szPassword;
  2218. }
  2219. TCHAR szUserName[200];
  2220. LPTSTR pszUserName = NULL;
  2221. if (1 == IsDlgButtonChecked(hwnd, IDC_USER))
  2222. {
  2223. GetDlgItemText(hwnd, IDC_USER_TEXT, szUserName, ARRAYLEN(szUserName));
  2224. pszUserName = szUserName;
  2225. }
  2226. NETRESOURCE net;
  2227. net.dwScope = 0;
  2228. net.dwType = dwType;
  2229. net.dwDisplayType = 0;
  2230. net.dwUsage = 0;
  2231. net.lpLocalName = pszLocalName;
  2232. net.lpRemoteName = pszRemoteName;
  2233. net.lpComment = NULL;
  2234. net.lpProvider = pszProviderName;
  2235. DWORD dwResult = 0;
  2236. // clear it
  2237. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  2238. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  2239. SetDlgItemText(hwnd, IDC_ACCESSNAME, TEXT(""));
  2240. SetDlgItemText(hwnd, IDC_RESULT, TEXT(""));
  2241. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  2242. DWORD dw = WNetUseConnection(
  2243. hwndParent,
  2244. &net,
  2245. pszUserName,
  2246. pszPassword,
  2247. dwFlags,
  2248. pszAccessName,
  2249. &dwBufferSize,
  2250. &dwResult);
  2251. SetCursor(hOldCursor);
  2252. TCHAR sz[500];
  2253. wsprintf(sz, TEXT("%d"), dwBufferSize);
  2254. SetDlgItemText(hwnd, IDC_BUFSIZE, sz);
  2255. if (NULL == pszAccessName)
  2256. {
  2257. SetDlgItemText(hwnd, IDC_ACCESSNAME, TEXT("(null)"));
  2258. }
  2259. else
  2260. {
  2261. SetDlgItemText(hwnd, IDC_ACCESSNAME, pszAccessName);
  2262. }
  2263. wsprintf(sz, TEXT("%d (0x%08lx)"), dwResult, dwResult);
  2264. if (dwResult & CONNECT_REFCOUNT)
  2265. {
  2266. _tcscat(sz, TEXT(" CONNECT_REFCOUNT"));
  2267. dwResult &= ~CONNECT_REFCOUNT;
  2268. }
  2269. if (dwResult & CONNECT_LOCALDRIVE)
  2270. {
  2271. _tcscat(sz, TEXT(" CONNECT_LOCALDRIVE"));
  2272. dwResult &= ~CONNECT_LOCALDRIVE;
  2273. }
  2274. if (dwResult != 0)
  2275. {
  2276. _tcscat(sz, TEXT(" + unknown"));
  2277. }
  2278. SetDlgItemText(hwnd, IDC_RESULT, sz);
  2279. DoError(hwnd, dw);
  2280. return TRUE;
  2281. }
  2282. case IDOK:
  2283. EndDialog(hwnd, TRUE);
  2284. return TRUE;
  2285. case IDC_LOCAL:
  2286. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT),
  2287. (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL)));
  2288. return TRUE;
  2289. case IDC_REMOTE:
  2290. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT),
  2291. (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE)));
  2292. return TRUE;
  2293. case IDC_PROVIDER:
  2294. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT),
  2295. (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER)));
  2296. return TRUE;
  2297. case IDC_PASSWORD:
  2298. EnableWindow(GetDlgItem(hwnd, IDC_PASSWORD_TEXT),
  2299. (1 == IsDlgButtonChecked(hwnd, IDC_PASSWORD)));
  2300. return TRUE;
  2301. case IDC_USER:
  2302. EnableWindow(GetDlgItem(hwnd, IDC_USER_TEXT),
  2303. (1 == IsDlgButtonChecked(hwnd, IDC_USER)));
  2304. return TRUE;
  2305. } // end switch (LOWORD(wParam))
  2306. return FALSE;
  2307. }
  2308. default:
  2309. return FALSE; // didn't process
  2310. }
  2311. }
  2312. INT_PTR CALLBACK
  2313. GetResourceInformationDlgProc(
  2314. IN HWND hwnd,
  2315. IN UINT uMsg,
  2316. IN WPARAM wParam,
  2317. IN LPARAM lParam
  2318. )
  2319. {
  2320. switch (uMsg)
  2321. {
  2322. case WM_INITDIALOG:
  2323. PlaceIt(hwnd);
  2324. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  2325. SetDlgItemText(hwnd, IDC_REMOTE_TEXT, TEXT(""));
  2326. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT), FALSE);
  2327. CheckDlgButton(hwnd, IDC_REMOTE_TEXT, 0);
  2328. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  2329. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT), FALSE);
  2330. CheckDlgButton(hwnd, IDC_PROVIDER_TEXT, 0);
  2331. CheckRadioButton(hwnd, IDC_DISK, IDC_ANY, IDC_DISK);
  2332. SetDlgItemText(hwnd, IDC_RETURNREMOTE, TEXT(""));
  2333. SetDlgItemText(hwnd, IDC_RETURNPROVIDER, TEXT(""));
  2334. SetDlgItemText(hwnd, IDC_RETURNSCOPE, TEXT(""));
  2335. SetDlgItemText(hwnd, IDC_RETURNTYPE, TEXT(""));
  2336. SetDlgItemText(hwnd, IDC_RETURNUSAGE, TEXT(""));
  2337. SetDlgItemText(hwnd, IDC_RETURNSYSTEM, TEXT(""));
  2338. SetDlgItemText(hwnd, IDC_RETURNDISPLAYTYPE, TEXT(""));
  2339. SetDlgItemText(hwnd, IDC_RETURNLOCALNAME, TEXT(""));
  2340. SetDlgItemText(hwnd, IDC_RETURNCOMMENT, TEXT(""));
  2341. SetDlgItemInt (hwnd, IDC_BUFSIZEIN, sizeof(NETRESOURCE) + MAX_PATH*2, FALSE);
  2342. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  2343. return 1; // didn't call SetFocus
  2344. case WM_COMMAND:
  2345. {
  2346. switch (LOWORD(wParam))
  2347. {
  2348. case IDC_GO:
  2349. {
  2350. DWORD dwType = 0;
  2351. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  2352. {
  2353. dwType = RESOURCETYPE_DISK;
  2354. }
  2355. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  2356. {
  2357. dwType = RESOURCETYPE_PRINT;
  2358. }
  2359. else if (1 == IsDlgButtonChecked(hwnd, IDC_ANY))
  2360. {
  2361. dwType = RESOURCETYPE_ANY;
  2362. }
  2363. else
  2364. {
  2365. // internal error
  2366. }
  2367. TCHAR szRemoteName[200];
  2368. LPTSTR pszRemoteName = NULL;
  2369. if (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE))
  2370. {
  2371. GetDlgItemText(hwnd, IDC_REMOTE_TEXT, szRemoteName, ARRAYLEN(szRemoteName));
  2372. pszRemoteName = szRemoteName;
  2373. }
  2374. TCHAR szProviderName[200];
  2375. LPTSTR pszProviderName = NULL;
  2376. if (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER))
  2377. {
  2378. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderName, ARRAYLEN(szProviderName));
  2379. pszProviderName = szProviderName;
  2380. }
  2381. NETRESOURCE net;
  2382. net.dwScope = 0;
  2383. net.dwType = dwType;
  2384. net.dwDisplayType = 0;
  2385. net.dwUsage = 0;
  2386. net.lpLocalName = NULL;
  2387. net.lpRemoteName = pszRemoteName;
  2388. net.lpComment = NULL;
  2389. net.lpProvider = pszProviderName;
  2390. DWORD bufSizeIn = GetDlgItemInt(hwnd, IDC_BUFSIZEIN, NULL, FALSE);
  2391. DWORD bufSize = bufSizeIn;
  2392. LPTSTR lpSystem = NULL;
  2393. // clear it
  2394. SetDlgItemText(hwnd, IDC_RETURNREMOTE, TEXT(""));
  2395. SetDlgItemText(hwnd, IDC_RETURNPROVIDER, TEXT(""));
  2396. SetDlgItemText(hwnd, IDC_RETURNSCOPE, TEXT(""));
  2397. SetDlgItemText(hwnd, IDC_RETURNTYPE, TEXT(""));
  2398. SetDlgItemText(hwnd, IDC_RETURNUSAGE, TEXT(""));
  2399. SetDlgItemText(hwnd, IDC_RETURNSYSTEM, TEXT(""));
  2400. SetDlgItemText(hwnd, IDC_RETURNDISPLAYTYPE, TEXT(""));
  2401. SetDlgItemText(hwnd, IDC_RETURNLOCALNAME, TEXT(""));
  2402. SetDlgItemText(hwnd, IDC_RETURNCOMMENT, TEXT(""));
  2403. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  2404. SetDlgItemInt (hwnd, IDC_BUFSIZEIN, bufSizeIn, FALSE);
  2405. HLOCAL buf = LocalAlloc(0, bufSizeIn);
  2406. if (buf == NULL)
  2407. {
  2408. SetDlgItemText(hwnd, IDC_ERROR,
  2409. TEXT("The test couldn't allocate a heap buffer of that size."));
  2410. Beep(1000, 150);
  2411. return TRUE;
  2412. }
  2413. LPNETRESOURCE pnrOut = (LPNETRESOURCE)buf;
  2414. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  2415. DWORD dw = WNetGetResourceInformation(
  2416. &net,
  2417. (LPVOID)buf,
  2418. &bufSize,
  2419. &lpSystem);
  2420. SetCursor(hOldCursor);
  2421. DoError(hwnd, dw);
  2422. TCHAR szBuf[MAX_PATH];
  2423. if (WN_SUCCESS == dw)
  2424. {
  2425. SetDlgItemText(hwnd, IDC_RETURNREMOTE,
  2426. (NULL == pnrOut->lpRemoteName) ? TEXT("<none>") : pnrOut->lpRemoteName);
  2427. SetDlgItemText(hwnd, IDC_RETURNPROVIDER,
  2428. (NULL == pnrOut->lpProvider) ? TEXT("<none>") : pnrOut->lpProvider);
  2429. GetScopeString(szBuf, pnrOut);
  2430. SetDlgItemText(hwnd, IDC_RETURNSCOPE, szBuf);
  2431. GetTypeString(szBuf, pnrOut);
  2432. SetDlgItemText(hwnd, IDC_RETURNTYPE, szBuf);
  2433. GetUsageString(szBuf, pnrOut);
  2434. SetDlgItemText(hwnd, IDC_RETURNUSAGE, szBuf);
  2435. SetDlgItemText(hwnd, IDC_RETURNSYSTEM,
  2436. (NULL == lpSystem) ? TEXT("<none>") : lpSystem);
  2437. GetDisplayTypeString(szBuf, pnrOut);
  2438. SetDlgItemText(hwnd, IDC_RETURNDISPLAYTYPE, szBuf);
  2439. SetDlgItemText(hwnd, IDC_RETURNLOCALNAME,
  2440. (NULL == pnrOut->lpLocalName) ? TEXT("<none>") : pnrOut->lpLocalName);
  2441. SetDlgItemText(hwnd, IDC_RETURNCOMMENT,
  2442. (NULL == pnrOut->lpComment) ? TEXT("<none>") : pnrOut->lpComment);
  2443. }
  2444. wsprintf(szBuf, TEXT("%d"), bufSize);
  2445. SetDlgItemText(hwnd, IDC_BUFSIZE, szBuf);
  2446. LocalFree(buf);
  2447. return TRUE;
  2448. }
  2449. case IDOK:
  2450. EndDialog(hwnd, TRUE);
  2451. return TRUE;
  2452. case IDC_REMOTE:
  2453. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT),
  2454. (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE)));
  2455. return TRUE;
  2456. case IDC_PROVIDER:
  2457. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT),
  2458. (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER)));
  2459. return TRUE;
  2460. } // end switch (LOWORD(wParam))
  2461. return FALSE;
  2462. }
  2463. default:
  2464. return FALSE; // didn't process
  2465. }
  2466. }
  2467. INT_PTR CALLBACK
  2468. GetResourceParentDlgProc(
  2469. IN HWND hwnd,
  2470. IN UINT uMsg,
  2471. IN WPARAM wParam,
  2472. IN LPARAM lParam
  2473. )
  2474. {
  2475. switch (uMsg)
  2476. {
  2477. case WM_INITDIALOG:
  2478. PlaceIt(hwnd);
  2479. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  2480. SetDlgItemText(hwnd, IDC_REMOTE_TEXT, TEXT(""));
  2481. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT), FALSE);
  2482. CheckDlgButton(hwnd, IDC_REMOTE_TEXT, 0);
  2483. SetDlgItemText(hwnd, IDC_PROVIDER_TEXT, TEXT(""));
  2484. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT), FALSE);
  2485. CheckDlgButton(hwnd, IDC_PROVIDER_TEXT, 0);
  2486. CheckRadioButton(hwnd, IDC_DISK, IDC_ANY, IDC_DISK);
  2487. SetDlgItemText(hwnd, IDC_RETURNREMOTE, TEXT(""));
  2488. SetDlgItemText(hwnd, IDC_RETURNPROVIDER, TEXT(""));
  2489. SetDlgItemText(hwnd, IDC_RETURNTYPE, TEXT(""));
  2490. SetDlgItemText(hwnd, IDC_RETURNUSAGE, TEXT(""));
  2491. SetDlgItemText(hwnd, IDC_RETURNSCOPE, TEXT(""));
  2492. SetDlgItemText(hwnd, IDC_RETURNDISPLAYTYPE, TEXT(""));
  2493. SetDlgItemText(hwnd, IDC_RETURNLOCALNAME, TEXT(""));
  2494. SetDlgItemText(hwnd, IDC_RETURNCOMMENT, TEXT(""));
  2495. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  2496. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  2497. return 1; // didn't call SetFocus
  2498. case WM_COMMAND:
  2499. {
  2500. switch (LOWORD(wParam))
  2501. {
  2502. case IDC_GO:
  2503. {
  2504. DWORD dwType = 0;
  2505. if (1 == IsDlgButtonChecked(hwnd, IDC_DISK))
  2506. {
  2507. dwType = RESOURCETYPE_DISK;
  2508. }
  2509. else if (1 == IsDlgButtonChecked(hwnd, IDC_PRINTER))
  2510. {
  2511. dwType = RESOURCETYPE_PRINT;
  2512. }
  2513. else if (1 == IsDlgButtonChecked(hwnd, IDC_ANY))
  2514. {
  2515. dwType = RESOURCETYPE_ANY;
  2516. }
  2517. else
  2518. {
  2519. // internal error
  2520. }
  2521. TCHAR szRemoteName[200];
  2522. LPTSTR pszRemoteName = NULL;
  2523. if (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE))
  2524. {
  2525. GetDlgItemText(hwnd, IDC_REMOTE_TEXT, szRemoteName, ARRAYLEN(szRemoteName));
  2526. pszRemoteName = szRemoteName;
  2527. }
  2528. TCHAR szProviderName[200];
  2529. LPTSTR pszProviderName = NULL;
  2530. if (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER))
  2531. {
  2532. GetDlgItemText(hwnd, IDC_PROVIDER_TEXT, szProviderName, ARRAYLEN(szProviderName));
  2533. pszProviderName = szProviderName;
  2534. }
  2535. NETRESOURCE net;
  2536. net.dwScope = 0;
  2537. net.dwType = dwType;
  2538. net.dwDisplayType = 0;
  2539. net.dwUsage = 0;
  2540. net.lpLocalName = NULL;
  2541. net.lpRemoteName = pszRemoteName;
  2542. net.lpComment = NULL;
  2543. net.lpProvider = pszProviderName;
  2544. BYTE buf[sizeof(NETRESOURCE) + MAX_PATH*2];
  2545. DWORD bufSize = sizeof(buf);
  2546. DWORD bufSizeIn = bufSize;
  2547. LPNETRESOURCE pnrOut = (LPNETRESOURCE)buf;
  2548. // clear it
  2549. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  2550. SetDlgItemText(hwnd, IDC_RETURNREMOTE, TEXT(""));
  2551. SetDlgItemText(hwnd, IDC_RETURNPROVIDER, TEXT(""));
  2552. SetDlgItemText(hwnd, IDC_RETURNTYPE, TEXT(""));
  2553. SetDlgItemText(hwnd, IDC_RETURNUSAGE, TEXT(""));
  2554. SetDlgItemText(hwnd, IDC_RETURNSCOPE, TEXT(""));
  2555. SetDlgItemText(hwnd, IDC_RETURNDISPLAYTYPE, TEXT(""));
  2556. SetDlgItemText(hwnd, IDC_RETURNLOCALNAME, TEXT(""));
  2557. SetDlgItemText(hwnd, IDC_RETURNCOMMENT, TEXT(""));
  2558. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  2559. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  2560. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  2561. DWORD dw = WNetGetResourceParent(
  2562. &net,
  2563. (LPVOID)buf,
  2564. &bufSize);
  2565. SetCursor(hOldCursor);
  2566. DoError(hwnd, dw);
  2567. TCHAR szBuf[MAX_PATH];
  2568. if (WN_SUCCESS == dw)
  2569. {
  2570. SetDlgItemText(hwnd, IDC_RETURNREMOTE,
  2571. (NULL == pnrOut->lpRemoteName) ? TEXT("<none>") : pnrOut->lpRemoteName);
  2572. SetDlgItemText(hwnd, IDC_RETURNPROVIDER,
  2573. (NULL == pnrOut->lpProvider) ? TEXT("<none>") : pnrOut->lpProvider);
  2574. GetTypeString(szBuf, pnrOut);
  2575. SetDlgItemText(hwnd, IDC_RETURNTYPE, szBuf);
  2576. GetUsageString(szBuf, pnrOut);
  2577. SetDlgItemText(hwnd, IDC_RETURNUSAGE, szBuf);
  2578. GetScopeString(szBuf, pnrOut);
  2579. SetDlgItemText(hwnd, IDC_RETURNSCOPE, szBuf);
  2580. GetDisplayTypeString(szBuf, pnrOut);
  2581. SetDlgItemText(hwnd, IDC_RETURNDISPLAYTYPE, szBuf);
  2582. SetDlgItemText(hwnd, IDC_RETURNLOCALNAME,
  2583. (NULL == pnrOut->lpLocalName) ? TEXT("<none>") : pnrOut->lpLocalName);
  2584. SetDlgItemText(hwnd, IDC_RETURNCOMMENT,
  2585. (NULL == pnrOut->lpComment) ? TEXT("<none>") : pnrOut->lpComment);
  2586. }
  2587. wsprintf(szBuf, TEXT("%d"), bufSize);
  2588. SetDlgItemText(hwnd, IDC_BUFSIZE, szBuf);
  2589. wsprintf(szBuf, TEXT("%d"), bufSizeIn);
  2590. SetDlgItemText(hwnd, IDC_BUFSIZEIN, szBuf);
  2591. return TRUE;
  2592. }
  2593. case IDOK:
  2594. EndDialog(hwnd, TRUE);
  2595. return TRUE;
  2596. case IDC_REMOTE:
  2597. EnableWindow(GetDlgItem(hwnd, IDC_REMOTE_TEXT),
  2598. (1 == IsDlgButtonChecked(hwnd, IDC_REMOTE)));
  2599. return TRUE;
  2600. case IDC_PROVIDER:
  2601. EnableWindow(GetDlgItem(hwnd, IDC_PROVIDER_TEXT),
  2602. (1 == IsDlgButtonChecked(hwnd, IDC_PROVIDER)));
  2603. return TRUE;
  2604. } // end switch (LOWORD(wParam))
  2605. return FALSE;
  2606. }
  2607. default:
  2608. return FALSE; // didn't process
  2609. }
  2610. }
  2611. INT_PTR CALLBACK
  2612. GetUniversalNameDlgProc(
  2613. IN HWND hwnd,
  2614. IN UINT uMsg,
  2615. IN WPARAM wParam,
  2616. IN LPARAM lParam
  2617. )
  2618. {
  2619. switch (uMsg)
  2620. {
  2621. case WM_INITDIALOG:
  2622. PlaceIt(hwnd);
  2623. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  2624. SetDlgItemText(hwnd, IDC_LOCAL_TEXT, TEXT(""));
  2625. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT), FALSE);
  2626. CheckDlgButton(hwnd, IDC_LOCAL_TEXT, 0);
  2627. CheckRadioButton(hwnd, IDC_UNIVERSALLEVEL, IDC_REMOTELEVEL, IDC_UNIVERSALLEVEL);
  2628. SetDlgItemText(hwnd, IDC_RETURNUNIVERSAL, TEXT(""));
  2629. SetDlgItemText(hwnd, IDC_RETURNCONNECTION, TEXT(""));
  2630. SetDlgItemText(hwnd, IDC_RETURNREMAINING, TEXT(""));
  2631. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  2632. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  2633. return 1; // didn't call SetFocus
  2634. case WM_COMMAND:
  2635. {
  2636. switch (LOWORD(wParam))
  2637. {
  2638. case IDC_GO:
  2639. {
  2640. DWORD dwInfoLevel = 0;
  2641. if (1 == IsDlgButtonChecked(hwnd, IDC_UNIVERSALLEVEL))
  2642. {
  2643. dwInfoLevel = UNIVERSAL_NAME_INFO_LEVEL;
  2644. }
  2645. else if (1 == IsDlgButtonChecked(hwnd, IDC_REMOTELEVEL))
  2646. {
  2647. dwInfoLevel = REMOTE_NAME_INFO_LEVEL;
  2648. }
  2649. else
  2650. {
  2651. // internal error
  2652. }
  2653. TCHAR szLocalName[200];
  2654. LPTSTR pszLocalName = NULL;
  2655. if (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL))
  2656. {
  2657. GetDlgItemText(hwnd, IDC_LOCAL_TEXT, szLocalName, ARRAYLEN(szLocalName));
  2658. pszLocalName = szLocalName;
  2659. }
  2660. BYTE buf[MAX_PATH*4]; // a large guess
  2661. DWORD bufSize = sizeof(buf);
  2662. DWORD bufSizeIn = bufSize;
  2663. // clear it
  2664. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  2665. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  2666. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  2667. SetDlgItemText(hwnd, IDC_RETURNUNIVERSAL, TEXT(""));
  2668. SetDlgItemText(hwnd, IDC_RETURNCONNECTION, TEXT(""));
  2669. SetDlgItemText(hwnd, IDC_RETURNREMAINING, TEXT(""));
  2670. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  2671. DWORD dw = WNetGetUniversalName(
  2672. pszLocalName,
  2673. dwInfoLevel,
  2674. (LPVOID)buf,
  2675. &bufSize);
  2676. SetCursor(hOldCursor);
  2677. DoError(hwnd, dw);
  2678. TCHAR szBuf[MAX_PATH];
  2679. if (WN_SUCCESS == dw || WN_CONNECTION_CLOSED == dw)
  2680. {
  2681. switch (dwInfoLevel)
  2682. {
  2683. case UNIVERSAL_NAME_INFO_LEVEL:
  2684. {
  2685. LPUNIVERSAL_NAME_INFO pInfo = (LPUNIVERSAL_NAME_INFO)buf;
  2686. SetDlgItemText(hwnd, IDC_RETURNUNIVERSAL,
  2687. (NULL == pInfo->lpUniversalName) ? TEXT("<none>") : pInfo->lpUniversalName);
  2688. SetDlgItemText(hwnd, IDC_RETURNCONNECTION, TEXT("N/A"));
  2689. SetDlgItemText(hwnd, IDC_RETURNREMAINING, TEXT("N/A"));
  2690. break;
  2691. }
  2692. case REMOTE_NAME_INFO_LEVEL:
  2693. {
  2694. LPREMOTE_NAME_INFO pInfo = (LPREMOTE_NAME_INFO)buf;
  2695. SetDlgItemText(hwnd, IDC_RETURNUNIVERSAL,
  2696. (NULL == pInfo->lpUniversalName) ? TEXT("<none>") : pInfo->lpUniversalName);
  2697. SetDlgItemText(hwnd, IDC_RETURNCONNECTION,
  2698. (NULL == pInfo->lpConnectionName) ? TEXT("<none>") : pInfo->lpConnectionName);
  2699. SetDlgItemText(hwnd, IDC_RETURNREMAINING,
  2700. (NULL == pInfo->lpRemainingPath) ? TEXT("<none>") : pInfo->lpRemainingPath);
  2701. break;
  2702. }
  2703. default:
  2704. // a bug!
  2705. break;
  2706. }
  2707. }
  2708. wsprintf(szBuf, TEXT("%d"), bufSize);
  2709. SetDlgItemText(hwnd, IDC_BUFSIZE, szBuf);
  2710. wsprintf(szBuf, TEXT("%d"), bufSizeIn);
  2711. SetDlgItemText(hwnd, IDC_BUFSIZEIN, szBuf);
  2712. return TRUE;
  2713. }
  2714. case IDOK:
  2715. EndDialog(hwnd, TRUE);
  2716. return TRUE;
  2717. case IDC_LOCAL:
  2718. EnableWindow(GetDlgItem(hwnd, IDC_LOCAL_TEXT),
  2719. (1 == IsDlgButtonChecked(hwnd, IDC_LOCAL)));
  2720. return TRUE;
  2721. } // end switch (LOWORD(wParam))
  2722. return FALSE;
  2723. }
  2724. default:
  2725. return FALSE; // didn't process
  2726. }
  2727. }
  2728. INT_PTR CALLBACK
  2729. GetUserDlgProc(
  2730. IN HWND hwnd,
  2731. IN UINT uMsg,
  2732. IN WPARAM wParam,
  2733. IN LPARAM lParam
  2734. )
  2735. {
  2736. switch (uMsg)
  2737. {
  2738. case WM_INITDIALOG:
  2739. PlaceIt(hwnd);
  2740. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  2741. SetDlgItemText(hwnd, IDC_NAME_TEXT, TEXT(""));
  2742. EnableWindow(GetDlgItem(hwnd, IDC_NAME_TEXT), FALSE);
  2743. CheckDlgButton(hwnd, IDC_NAME_TEXT, 0);
  2744. SetDlgItemText(hwnd, IDC_RETURNUSER, TEXT(""));
  2745. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  2746. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  2747. return 1; // didn't call SetFocus
  2748. case WM_COMMAND:
  2749. {
  2750. switch (LOWORD(wParam))
  2751. {
  2752. case IDC_GO:
  2753. {
  2754. TCHAR szName[200];
  2755. LPTSTR pszName = NULL;
  2756. if (1 == IsDlgButtonChecked(hwnd, IDC_NAME))
  2757. {
  2758. GetDlgItemText(hwnd, IDC_NAME_TEXT, szName, ARRAYLEN(szName));
  2759. pszName = szName;
  2760. }
  2761. TCHAR szUserName[MAX_PATH];
  2762. DWORD bufSize = ARRAYLEN(szUserName);
  2763. DWORD bufSizeIn = bufSize;
  2764. // clear it
  2765. SetDlgItemText(hwnd, IDC_ERROR, TEXT(""));
  2766. SetDlgItemText(hwnd, IDC_RETURNUSER, TEXT(""));
  2767. SetDlgItemText(hwnd, IDC_BUFSIZE, TEXT(""));
  2768. SetDlgItemText(hwnd, IDC_BUFSIZEIN, TEXT(""));
  2769. HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  2770. DWORD dw = WNetGetUser(pszName, szUserName, &bufSize);
  2771. SetCursor(hOldCursor);
  2772. DoError(hwnd, dw);
  2773. TCHAR szBuf[MAX_PATH];
  2774. if (WN_SUCCESS == dw)
  2775. {
  2776. SetDlgItemText(hwnd, IDC_RETURNUSER, szUserName);
  2777. }
  2778. else
  2779. {
  2780. SetDlgItemText(hwnd, IDC_RETURNUSER, TEXT(""));
  2781. }
  2782. wsprintf(szBuf, TEXT("%d"), bufSize);
  2783. SetDlgItemText(hwnd, IDC_BUFSIZE, szBuf);
  2784. wsprintf(szBuf, TEXT("%d"), bufSizeIn);
  2785. SetDlgItemText(hwnd, IDC_BUFSIZEIN, szBuf);
  2786. return TRUE;
  2787. }
  2788. case IDOK:
  2789. EndDialog(hwnd, TRUE);
  2790. return TRUE;
  2791. case IDC_NAME:
  2792. EnableWindow(GetDlgItem(hwnd, IDC_NAME_TEXT),
  2793. (1 == IsDlgButtonChecked(hwnd, IDC_NAME)));
  2794. return TRUE;
  2795. } // end switch (LOWORD(wParam))
  2796. return FALSE;
  2797. }
  2798. default:
  2799. return FALSE; // didn't process
  2800. }
  2801. }
  2802. DWORD CALLBACK
  2803. DialogThreadProc(
  2804. LPVOID lpThreadParameter
  2805. )
  2806. {
  2807. DWORD idCmd = PtrToUlong(lpThreadParameter);
  2808. switch (idCmd)
  2809. {
  2810. case IDC_CONNECTIONDIALOG1:
  2811. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_CONNECTIONDIALOG1), NULL, Connection1DlgProc);
  2812. break;
  2813. case IDC_DISCONNECTDIALOG1:
  2814. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DISCONNECTDIALOG1), NULL, Disconnect1DlgProc);
  2815. break;
  2816. case IDC_CONNECTIONDIALOG:
  2817. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_CONNECTIONDIALOG), NULL, ConnectionDlgProc);
  2818. break;
  2819. case IDC_DISCONNECTDIALOG:
  2820. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DISCONNECTDIALOG), NULL, DisconnectDlgProc);
  2821. break;
  2822. case IDC_CONNECTIONDIALOG2:
  2823. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_CONNECTIONDIALOG2), NULL, Connection2DlgProc);
  2824. break;
  2825. case IDC_DISCONNECTDIALOG2:
  2826. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DISCONNECTDIALOG2), NULL, Disconnect2DlgProc);
  2827. break;
  2828. case IDC_BROWSEDIALOG:
  2829. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_BROWSEDIALOG), NULL, BrowseDlgProc);
  2830. break;
  2831. case IDC_GETCONNECTION:
  2832. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETCONNECTION), NULL, GetConnectionDlgProc);
  2833. break;
  2834. case IDC_GETCONNECTION2:
  2835. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETCONNECTION2), NULL, GetConnectionDlgProc2);
  2836. break;
  2837. case IDC_GETCONNECTION3:
  2838. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETCONNECTION3), NULL, GetConnection3DlgProc);
  2839. break;
  2840. case IDC_GETCONNECTIONPERFORMANCE:
  2841. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETCONNECTIONPERFORMANCE), NULL, GetConnectionPerformanceDlgProc);
  2842. break;
  2843. case IDC_FORMATNETWORKNAME:
  2844. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_FORMATNETWORKNAME), NULL, FormatNetworkNameDlgProc);
  2845. break;
  2846. case IDC_GETNETWORKINFORMATION:
  2847. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETNETWORKINFORMATION), NULL, GetNetworkInformationDlgProc);
  2848. break;
  2849. case IDC_GETPROVIDERNAME:
  2850. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETPROVIDERNAME), NULL, GetProviderNameDlgProc);
  2851. break;
  2852. case IDC_GETPROVIDERTYPE:
  2853. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETPROVIDERTYPE), NULL, GetProviderTypeDlgProc);
  2854. break;
  2855. case IDC_CANCELCONNECTION:
  2856. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_CANCELCONNECTION), NULL, CancelConnectionDlgProc);
  2857. break;
  2858. case IDC_CANCELCONNECTION2:
  2859. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_CANCELCONNECTION2), NULL, CancelConnection2DlgProc);
  2860. break;
  2861. case IDC_ADDCONNECTION:
  2862. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ADDCONNECTION), NULL, AddConnectionDlgProc);
  2863. break;
  2864. case IDC_ADDCONNECTION2:
  2865. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ADDCONNECTION2), NULL, AddConnection2DlgProc);
  2866. break;
  2867. case IDC_ADDCONNECTION3:
  2868. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ADDCONNECTION3), NULL, AddConnection3DlgProc);
  2869. break;
  2870. case IDC_USECONNECTION:
  2871. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_USECONNECTION), NULL, UseConnectionDlgProc);
  2872. break;
  2873. case IDC_GETRESOURCEINFORMATION:
  2874. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETRESOURCEINFORMATION), NULL, GetResourceInformationDlgProc);
  2875. break;
  2876. case IDC_GETRESOURCEPARENT:
  2877. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETRESOURCEPARENT), NULL, GetResourceParentDlgProc);
  2878. break;
  2879. case IDC_GETUNIVERSALNAME:
  2880. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETUNIVERSALNAME), NULL, GetUniversalNameDlgProc);
  2881. break;
  2882. case IDC_GETUSER:
  2883. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_GETUSER), NULL, GetUserDlgProc);
  2884. break;
  2885. }
  2886. return 0;
  2887. }
  2888. BOOL CALLBACK
  2889. DlgProc(
  2890. IN HWND hwnd,
  2891. IN UINT uMsg,
  2892. IN WPARAM wParam,
  2893. IN LPARAM lParam
  2894. )
  2895. {
  2896. switch (uMsg)
  2897. {
  2898. case WM_INITDIALOG:
  2899. #ifdef UNICODE
  2900. SetWindowText(hwnd, TEXT("WNet tests -- UNICODE strings version"));
  2901. #else // UNICODE
  2902. SetWindowText(hwnd, TEXT("WNet tests -- ANSI strings version"));
  2903. #endif // UNICODE
  2904. return 1; // didn't call SetFocus
  2905. case WM_DEVICECHANGE:
  2906. {
  2907. TCHAR sz[500];
  2908. _tcscpy(sz, TEXT("WM_DEVICECHANGE "));
  2909. LPTSTR pszType = NULL;
  2910. switch (wParam)
  2911. {
  2912. case DBT_APPYBEGIN: pszType = TEXT("DBT_APPYBEGIN "); break;
  2913. case DBT_APPYEND: pszType = TEXT("DBT_APPYEND "); break;
  2914. case DBT_DEVNODES_CHANGED: pszType = TEXT("DBT_DEVNODES_CHANGED "); break;
  2915. case DBT_QUERYCHANGECONFIG: pszType = TEXT("DBT_QUERYCHANGECONFIG "); break;
  2916. case DBT_CONFIGCHANGED: pszType = TEXT("DBT_CONFIGCHANGED "); break;
  2917. case DBT_CONFIGCHANGECANCELED: pszType = TEXT("DBT_CONFIGCHANGECANCELED "); break;
  2918. case DBT_MONITORCHANGE: pszType = TEXT("DBT_MONITORCHANGE "); break;
  2919. case DBT_SHELLLOGGEDON: pszType = TEXT("DBT_SHELLLOGGEDON "); break;
  2920. case DBT_CONFIGMGAPI32: pszType = TEXT("DBT_CONFIGMGAPI32 "); break;
  2921. case DBT_VOLLOCKQUERYLOCK: pszType = TEXT("DBT_VOLLOCKQUERYLOCK "); break;
  2922. case DBT_VOLLOCKLOCKTAKEN: pszType = TEXT("DBT_VOLLOCKLOCKTAKEN "); break;
  2923. case DBT_VOLLOCKLOCKFAILED: pszType = TEXT("DBT_VOLLOCKLOCKFAILED "); break;
  2924. case DBT_VOLLOCKQUERYUNLOCK: pszType = TEXT("DBT_VOLLOCKQUERYUNLOCK "); break;
  2925. case DBT_VOLLOCKLOCKRELEASED: pszType = TEXT("DBT_VOLLOCKLOCKRELEASED "); break;
  2926. case DBT_VOLLOCKUNLOCKFAILED: pszType = TEXT("DBT_VOLLOCKUNLOCKFAILED "); break;
  2927. case DBT_NO_DISK_SPACE: pszType = TEXT("DBT_NO_DISK_SPACE "); break;
  2928. case DBT_DEVICEARRIVAL: pszType = TEXT("DBT_DEVICEARRIVAL "); break;
  2929. case DBT_DEVICEQUERYREMOVE: pszType = TEXT("DBT_DEVICEQUERYREMOVE "); break;
  2930. case DBT_DEVICEQUERYREMOVEFAILED: pszType = TEXT("DBT_DEVICEQUERYREMOVEFAILED "); break;
  2931. case DBT_DEVICEREMOVEPENDING: pszType = TEXT("DBT_DEVICEREMOVEPENDING "); break;
  2932. case DBT_DEVICEREMOVECOMPLETE: pszType = TEXT("DBT_DEVICEREMOVECOMPLETE "); break;
  2933. case DBT_DEVICETYPESPECIFIC: pszType = TEXT("DBT_DEVICETYPESPECIFIC "); break;
  2934. case DBT_VPOWERDAPI: pszType = TEXT("DBT_VPOWERDAPI "); break;
  2935. case DBT_USERDEFINED: pszType = TEXT("DBT_USERDEFINED "); break;
  2936. default: pszType = TEXT("Unknown "); break;
  2937. }
  2938. _tcscat(sz, pszType);
  2939. switch (wParam)
  2940. {
  2941. case DBT_DEVICEARRIVAL:
  2942. case DBT_DEVICEREMOVECOMPLETE:
  2943. {
  2944. _DEV_BROADCAST_HEADER* phdr = (_DEV_BROADCAST_HEADER*)lParam;
  2945. if (phdr->dbcd_devicetype == DBT_DEVTYP_VOLUME)
  2946. {
  2947. _tcscat(sz, TEXT("DBT_DEVTYP_VOLUME "));
  2948. DEV_BROADCAST_VOLUME* pdbv = (DEV_BROADCAST_VOLUME*)lParam;
  2949. TCHAR szT[4];
  2950. szT[1] = TEXT(':');
  2951. szT[2] = TEXT(' ');
  2952. szT[3] = TEXT('\0');
  2953. DWORD dw = pdbv->dbcv_unitmask;
  2954. DWORD count = 0;
  2955. while (dw > 0)
  2956. {
  2957. if (dw & 1)
  2958. {
  2959. szT[0] = (TCHAR)(TEXT('A') + count);
  2960. _tcscat(sz, szT);
  2961. }
  2962. ++count;
  2963. dw >>= 1;
  2964. }
  2965. switch (pdbv->dbcv_flags)
  2966. {
  2967. case DBTF_MEDIA: _tcscat(sz, TEXT("DBTF_MEDIA ")); break;
  2968. case DBTF_NET: _tcscat(sz, TEXT("DBTF_NET ")); break;
  2969. default: _tcscat(sz, TEXT("Unknown ")); break;
  2970. }
  2971. }
  2972. break;
  2973. }
  2974. }
  2975. _tcscat(sz, TEXT("\r\n"));
  2976. SendDlgItemMessage(hwnd, IDC_MESSAGES, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)sz);
  2977. }
  2978. case WM_COMMAND:
  2979. {
  2980. switch (LOWORD(wParam))
  2981. {
  2982. case IDC_CONNECTIONDIALOG1:
  2983. case IDC_DISCONNECTDIALOG1:
  2984. case IDC_CONNECTIONDIALOG2:
  2985. case IDC_DISCONNECTDIALOG2:
  2986. case IDC_CONNECTIONDIALOG:
  2987. case IDC_DISCONNECTDIALOG:
  2988. case IDC_BROWSEDIALOG:
  2989. case IDC_GETCONNECTION:
  2990. case IDC_GETCONNECTION2:
  2991. case IDC_GETCONNECTION3:
  2992. case IDC_GETCONNECTIONPERFORMANCE:
  2993. case IDC_FORMATNETWORKNAME:
  2994. case IDC_GETNETWORKINFORMATION:
  2995. case IDC_GETPROVIDERNAME:
  2996. case IDC_GETPROVIDERTYPE:
  2997. case IDC_CANCELCONNECTION:
  2998. case IDC_CANCELCONNECTION2:
  2999. case IDC_ADDCONNECTION:
  3000. case IDC_ADDCONNECTION2:
  3001. case IDC_ADDCONNECTION3:
  3002. case IDC_USECONNECTION:
  3003. case IDC_GETRESOURCEINFORMATION:
  3004. case IDC_GETRESOURCEPARENT:
  3005. case IDC_GETUNIVERSALNAME:
  3006. case IDC_GETUSER:
  3007. {
  3008. DWORD idThread;
  3009. HANDLE hThread = CreateThread(NULL, 0, DialogThreadProc, (LPVOID)(LOWORD(wParam)), 0, &idThread);
  3010. if (hThread)
  3011. {
  3012. CloseHandle(hThread);
  3013. }
  3014. else
  3015. {
  3016. MessageBox(hwnd, TEXT("Couldn't create dialog box thread"), TEXT("Error!"), MB_OK);
  3017. }
  3018. break;
  3019. }
  3020. case IDC_ENUMERATE:
  3021. DoEnumeration(hwnd);
  3022. break;
  3023. case IDOK:
  3024. EndDialog(hwnd, TRUE);
  3025. return TRUE;
  3026. }
  3027. return FALSE;
  3028. }
  3029. default:
  3030. return FALSE; // didn't process
  3031. }
  3032. }
  3033. int WINAPI
  3034. WinMain(
  3035. HINSTANCE hInstance,
  3036. HINSTANCE hPrevInstance,
  3037. LPSTR lpCmdLine,
  3038. int nShowCmd
  3039. )
  3040. {
  3041. g_hInstance = hInstance;
  3042. DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ROOT), NULL, (DLGPROC) DlgProc);
  3043. if (NULL != g_hInstanceMpr)
  3044. {
  3045. FreeLibrary(g_hInstanceMpr);
  3046. }
  3047. return 0;
  3048. }