Leaked source code of windows server 2003
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.

126 lines
3.1 KiB

  1. // RemoveFSPDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ConfigTest.h"
  5. #include "RemoveFSPDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. typedef unsigned long ULONG_PTR, *PULONG_PTR;
  12. typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
  13. #include "..\..\..\inc\fxsapip.h"
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CRemoveFSPDlg dialog
  16. CRemoveFSPDlg::CRemoveFSPDlg(HANDLE hFax, CWnd* pParent /*=NULL*/)
  17. : CDialog(CRemoveFSPDlg::IDD, pParent),
  18. m_hFax (hFax)
  19. {
  20. //{{AFX_DATA_INIT(CRemoveFSPDlg)
  21. m_cstrGUID = _T("");
  22. //}}AFX_DATA_INIT
  23. }
  24. void CRemoveFSPDlg::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CRemoveFSPDlg)
  28. DDX_Control(pDX, IDC_COMBO, m_cbFSPs);
  29. DDX_Text(pDX, IDC_GUID, m_cstrGUID);
  30. //}}AFX_DATA_MAP
  31. }
  32. BEGIN_MESSAGE_MAP(CRemoveFSPDlg, CDialog)
  33. //{{AFX_MSG_MAP(CRemoveFSPDlg)
  34. ON_BN_CLICKED(IDREMOVE, OnRemove)
  35. ON_CBN_SELCHANGE(IDC_COMBO, OnSelChangeCombo)
  36. //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CRemoveFSPDlg message handlers
  40. void CRemoveFSPDlg::OnRemove()
  41. {
  42. if (!UpdateData ())
  43. {
  44. return;
  45. }
  46. if (!FaxUnregisterServiceProviderEx(m_hFax, m_cstrGUID))
  47. {
  48. CString cs;
  49. cs.Format ("Failed while calling FaxUnregisterServiceProviderEx (%ld)",
  50. GetLastError ());
  51. AfxMessageBox (cs, MB_OK | MB_ICONHAND);
  52. return;
  53. }
  54. else
  55. {
  56. AfxMessageBox ("FSP successfully removed. You need to restart the service for the change to take effect", MB_OK | MB_ICONHAND);
  57. }
  58. }
  59. void
  60. CRemoveFSPDlg::RefreshList ()
  61. {
  62. PFAX_DEVICE_PROVIDER_INFO pFSPs;
  63. DWORD dwNumFSPs;
  64. CString cs;
  65. m_cbFSPs.ResetContent ();
  66. if (!FaxEnumerateProviders (m_hFax, &pFSPs, &dwNumFSPs))
  67. {
  68. cs.Format ("Failed while calling FaxEnumerateProviders (%ld)", GetLastError());
  69. AfxMessageBox (cs, MB_OK | MB_ICONHAND);
  70. return;
  71. }
  72. for (DWORD dw = 0; dw < dwNumFSPs; dw++)
  73. {
  74. int iIndex = m_cbFSPs.AddString (pFSPs[dw].lpctstrFriendlyName);
  75. CString *pCString = new CString (pFSPs[dw].lpctstrGUID);
  76. m_cbFSPs.SetItemData (iIndex, (DWORD) pCString);
  77. }
  78. if (!dwNumFSPs)
  79. {
  80. m_cbFSPs.EnableWindow (FALSE);
  81. }
  82. else
  83. {
  84. m_cbFSPs.SetCurSel (0);
  85. DWORD dwData = m_cbFSPs.GetItemData (0);
  86. m_cstrGUID = *((CString *)(dwData));
  87. }
  88. UpdateData (FALSE);
  89. FaxFreeBuffer (LPVOID(pFSPs));
  90. }
  91. BOOL CRemoveFSPDlg::OnInitDialog()
  92. {
  93. CDialog::OnInitDialog();
  94. RefreshList ();
  95. return TRUE; // return TRUE unless you set the focus to a control
  96. // EXCEPTION: OCX Property Pages should return FALSE
  97. }
  98. void CRemoveFSPDlg::OnSelChangeCombo()
  99. {
  100. int iIndex = m_cbFSPs.GetCurSel ();
  101. if (CB_ERR == iIndex)
  102. {
  103. return;
  104. }
  105. m_cstrGUID = *((CString *)(m_cbFSPs.GetItemData (iIndex)));
  106. UpdateData (FALSE);
  107. }