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.

177 lines
4.8 KiB

  1. //#--------------------------------------------------------------
  2. //
  3. // File: support.cpp
  4. //
  5. // Synopsis: holds the member functions for the support
  6. // class
  7. //
  8. // History: 5/8/97 MKarki Created
  9. //
  10. // Copyright (C) 1996-97 Microsoft Corporation
  11. // All rights reserved.
  12. //
  13. //----------------------------------------------------------------
  14. #include "stdafx.h"
  15. //++--------------------------------------------------------------
  16. //
  17. // Function: GetSupportInfo
  18. //
  19. // Synopsis: This is the public member function used to get the
  20. // support numbers
  21. //
  22. // Returns: BOOL - success/failure
  23. //
  24. // Arguments: PCHAR - returns the number
  25. //
  26. // History: MKarki Created 5/8/97
  27. //
  28. //----------------------------------------------------------------
  29. BOOL
  30. CSupport :: GetSupportInfo
  31. (
  32. LPTSTR pszNumber,
  33. DWORD dwCountryID
  34. )
  35. {
  36. HINSTANCE hPHBKDll = NULL;
  37. DWORD dwBufferSize = 0;
  38. BOOL bRetVal = FALSE;
  39. PFNGETSUPPORTNUMBERS pfnSupport = NULL;
  40. HRESULT hr = ERROR_SUCCESS;
  41. DWORD dwTotalNums = 0;
  42. DWORD dwIndex = 0;
  43. TraceMsg (TF_GENERAL, TEXT("Entering CSupport :: GetSupportInfo\r\n"));
  44. if (NULL == pszNumber)
  45. {
  46. TraceMsg (TF_GENERAL, TEXT("NULL = pszNumber\r\n"));
  47. goto Cleanup;
  48. }
  49. if (NULL == m_pSupportNumList)
  50. {
  51. //
  52. // being called the first time so load the info
  53. //
  54. hPHBKDll = LoadLibrary(PHBK_LIB);
  55. if (NULL == hPHBKDll)
  56. {
  57. TraceMsg (TF_GENERAL, TEXT("Failed on LoadLibrary API call with error:%d\r\n"),
  58. GetLastError () );
  59. goto Cleanup;
  60. }
  61. pfnSupport = (PFNGETSUPPORTNUMBERS)
  62. GetProcAddress(hPHBKDll,PHBK_SUPPORTNUMAPI);
  63. if (NULL == pfnSupport)
  64. {
  65. TraceMsg (TF_GENERAL, TEXT("Failed on GetProcAddress API call with error:%d\r\n"),
  66. GetLastError () );
  67. goto Cleanup;
  68. }
  69. //
  70. // call the first time to get the size needed
  71. //
  72. hr = pfnSupport ((PSUPPORTNUM)NULL, (PDWORD)&dwBufferSize);
  73. if (ERROR_SUCCESS != hr)
  74. {
  75. TraceMsg (TF_GENERAL, TEXT("Failed on GetSupportNumbers API call with error:%d\r\n"),
  76. hr);
  77. goto Cleanup;
  78. }
  79. //
  80. // allocate the required memory
  81. //
  82. m_pSupportNumList = (PSUPPORTNUM) GlobalAlloc (
  83. GPTR,
  84. dwBufferSize
  85. );
  86. if (NULL == m_pSupportNumList)
  87. {
  88. TraceMsg (TF_GENERAL, TEXT("Failed on GlobalAlloc API call with error:%d\r\n"),
  89. GetLastError ());
  90. goto Cleanup;
  91. }
  92. //
  93. // call second time for the info
  94. //
  95. hr = pfnSupport ((PSUPPORTNUM)m_pSupportNumList, (PDWORD)&dwBufferSize);
  96. if (ERROR_SUCCESS != hr)
  97. {
  98. TraceMsg (TF_GENERAL, TEXT("Failed on GetSupportNumbers API call with error:%d\r\n"),
  99. hr);
  100. goto Cleanup;
  101. }
  102. //
  103. // find out how many SUPPORTNUM structs we have in the
  104. // array
  105. m_dwTotalNums = dwBufferSize / sizeof (SUPPORTNUM);
  106. }
  107. //
  108. // get the current country code
  109. //
  110. for (dwIndex = 0; dwIndex < m_dwTotalNums; dwIndex++)
  111. {
  112. //
  113. // this struct says countrycode but is actually countryID
  114. //
  115. if (m_pSupportNumList[dwIndex].dwCountryCode == dwCountryID)
  116. {
  117. //
  118. // found a support phone number
  119. //
  120. CopyMemory (
  121. pszNumber,
  122. m_pSupportNumList[dwIndex].szPhoneNumber,
  123. sizeof (m_pSupportNumList[dwIndex].szPhoneNumber)
  124. );
  125. bRetVal = TRUE;
  126. goto Cleanup;
  127. }
  128. }
  129. Cleanup:
  130. if (NULL != hPHBKDll)
  131. FreeLibrary (hPHBKDll);
  132. TraceMsg (TF_GENERAL, TEXT("returning from CSupport :: GetSupportInfo function\r\n"));
  133. return (bRetVal);
  134. } // end of CSupport :: GetSupportInfo function
  135. //++--------------------------------------------------------------
  136. //
  137. // Function: ~CSupport
  138. //
  139. // Synopsis: This is the destructor of the CSupport class
  140. //
  141. //
  142. // Arguments: VOID
  143. //
  144. // History: MKarki Created 5/8/97
  145. //
  146. //----------------------------------------------------------------
  147. CSupport :: ~CSupport (
  148. VOID
  149. )
  150. {
  151. if (NULL != m_pSupportNumList)
  152. GlobalFree (m_pSupportNumList);
  153. } // end of ~CSupport function