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.

107 lines
2.0 KiB

  1. // NewSystemDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "snapin.h"
  5. #include "NewSystemDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CNewSystemDlg dialog
  13. CNewSystemDlg::CNewSystemDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CNewSystemDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CNewSystemDlg)
  17. m_sName = _T("");
  18. //}}AFX_DATA_INIT
  19. }
  20. void CNewSystemDlg::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(CNewSystemDlg)
  24. DDX_Text(pDX, IDC_EDIT_MACHINE_NAME, m_sName);
  25. DDV_MaxChars(pDX, m_sName, 255);
  26. //}}AFX_DATA_MAP
  27. }
  28. BEGIN_MESSAGE_MAP(CNewSystemDlg, CDialog)
  29. //{{AFX_MSG_MAP(CNewSystemDlg)
  30. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  31. //}}AFX_MSG_MAP
  32. END_MESSAGE_MAP()
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CNewSystemDlg message handlers
  35. void CNewSystemDlg::OnBrowse()
  36. {
  37. LPMALLOC pMalloc;
  38. if( ::SHGetMalloc(&pMalloc) == NOERROR )
  39. {
  40. BROWSEINFO bi;
  41. TCHAR szBuffer[MAX_PATH];
  42. LPITEMIDLIST pidlNet;
  43. LPITEMIDLIST pidl;
  44. if( ::SHGetSpecialFolderLocation(GetSafeHwnd(),CSIDL_NETWORK,&pidlNet) != NOERROR )
  45. return;
  46. CString sResString;
  47. sResString.LoadString(IDS_STRING_BROWSE_SYSTEM);
  48. bi.hwndOwner = GetSafeHwnd();
  49. bi.pidlRoot = pidlNet;
  50. bi.pszDisplayName = szBuffer;
  51. bi.lpszTitle = LPCTSTR(sResString);
  52. bi.ulFlags = BIF_BROWSEFORCOMPUTER;
  53. bi.lpfn = NULL;
  54. bi.lParam = 0;
  55. if( (pidl = ::SHBrowseForFolder(&bi)) != NULL )
  56. {
  57. m_sName = szBuffer;
  58. UpdateData(FALSE);
  59. pMalloc->Free(pidl);
  60. }
  61. pMalloc->Free(pidlNet);
  62. pMalloc->Release();
  63. }
  64. }
  65. void CNewSystemDlg::OnOK()
  66. {
  67. UpdateData();
  68. if( m_sName.IsEmpty() )
  69. {
  70. MessageBeep(MB_ICONEXCLAMATION);
  71. return;
  72. }
  73. IWbemServices* pServices = NULL;
  74. BOOL bAvail = FALSE;
  75. if( CnxGetConnection(m_sName,pServices,bAvail) == E_FAIL )
  76. {
  77. MessageBeep(MB_ICONEXCLAMATION);
  78. return;
  79. }
  80. if( pServices )
  81. {
  82. pServices->Release();
  83. }
  84. CDialog::OnOK();
  85. }