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.

209 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. install.c
  5. Abstract:
  6. This file contains common setup routines for fax.
  7. Author:
  8. Iv Garber (ivg) May-2001
  9. Environment:
  10. User Mode
  11. --*/
  12. #include "SetupUtil.h"
  13. #include "FaxSetup.h"
  14. #include "FaxUtil.h"
  15. DWORD CheckInstalledFax(
  16. IN DWORD dwFaxToCheck,
  17. OUT DWORD* pdwFaxInstalled
  18. )
  19. /*++
  20. Routine name : CheckInstalledFax
  21. Routine description:
  22. Checks whether SBS 5.0 / .NET SB3 / .NET RC1 client or SBS 5.0 Server are installed
  23. Arguments:
  24. IN DWORD dwFaxToCheck - input parameter, bit-wise combination of fxState_UpgradeApp_e values to define
  25. the fax applications to check for presence
  26. OUT DWORD *pdwFaxInstalled - output parameter, bit-wise combination of fxState_UpgradeApp_e values to define
  27. the fax applications that are present on the machine
  28. Author:
  29. Iv Vakaluk (IvG), May, 2002
  30. Return Value:
  31. DWORD - failure or success code
  32. --*/
  33. {
  34. DWORD dwReturn = NO_ERROR;
  35. HMODULE hMsiModule = NULL;
  36. PF_MSIQUERYPRODUCTSTATE pFunc = NULL;
  37. #ifdef UNICODE
  38. LPCSTR lpcstrFunctionName = "MsiQueryProductStateW";
  39. #else
  40. LPCSTR lpcstrFunctionName = "MsiQueryProductStateA";
  41. #endif
  42. DEBUG_FUNCTION_NAME(_T("CheckInstalledFaxClient"));
  43. *pdwFaxInstalled = FXSTATE_NONE;
  44. //
  45. // check that dwFaxToCheck is not empty
  46. //
  47. if (dwFaxToCheck == FXSTATE_NONE)
  48. {
  49. DebugPrintEx(DEBUG_MSG, _T("No Fax Application to check for its presence is given."));
  50. return dwReturn;
  51. }
  52. //
  53. // Load MSI DLL
  54. //
  55. hMsiModule = LoadLibrary(_T("msi.dll"));
  56. if (!hMsiModule)
  57. {
  58. //
  59. // MSI is not found ==> nothing is installed
  60. //
  61. DebugPrintEx(DEBUG_WRN, _T("Failed to LoadLibrary(msi.dll), ec=%ld."), GetLastError());
  62. return dwReturn;
  63. }
  64. pFunc = (PF_MSIQUERYPRODUCTSTATE)GetProcAddress(hMsiModule, lpcstrFunctionName);
  65. if (!pFunc)
  66. {
  67. dwReturn = GetLastError();
  68. DebugPrintEx(DEBUG_WRN, _T("Failed to GetProcAddress( ' %s ' ) on Msi, ec=%ld."), lpcstrFunctionName, dwReturn);
  69. goto FreeLibrary;
  70. }
  71. if (dwFaxToCheck & FXSTATE_SBS5_CLIENT)
  72. {
  73. //
  74. // check for the SBS 5.0 Client
  75. //
  76. if (INSTALLSTATE_DEFAULT == pFunc(PRODCODE_SBS5_CLIENT))
  77. {
  78. DebugPrintEx(DEBUG_MSG, _T("SBS 5.0 Client is installed on this machine."));
  79. *pdwFaxInstalled |= FXSTATE_SBS5_CLIENT;
  80. }
  81. }
  82. if (dwFaxToCheck & FXSTATE_SBS5_SERVER)
  83. {
  84. //
  85. // check for the SBS 5.0 Server
  86. //
  87. if (INSTALLSTATE_DEFAULT == pFunc(PRODCODE_SBS5_SERVER))
  88. {
  89. DebugPrintEx(DEBUG_MSG, _T("SBS 5.0 Server is installed on this machine."));
  90. *pdwFaxInstalled |= FXSTATE_SBS5_SERVER;
  91. }
  92. }
  93. if (dwFaxToCheck & FXSTATE_BETA3_CLIENT)
  94. {
  95. //
  96. // check for the .NET SB3 Client
  97. //
  98. if (INSTALLSTATE_DEFAULT == pFunc(PRODCODE_BETA3_CLIENT))
  99. {
  100. DebugPrintEx(DEBUG_MSG, _T(".NET SB3 Client is installed on this machine."));
  101. *pdwFaxInstalled |= FXSTATE_BETA3_CLIENT;
  102. }
  103. }
  104. if (dwFaxToCheck & FXSTATE_DOTNET_CLIENT)
  105. {
  106. //
  107. // check for the .NET RC1 Client
  108. //
  109. if (INSTALLSTATE_DEFAULT == pFunc(PRODCODE_DOTNET_CLIENT))
  110. {
  111. DebugPrintEx(DEBUG_MSG, _T(".NET RC1 Client is installed on this machine."));
  112. *pdwFaxInstalled |= FXSTATE_DOTNET_CLIENT;
  113. }
  114. }
  115. FreeLibrary:
  116. if (!FreeLibrary(hMsiModule))
  117. {
  118. dwReturn = GetLastError();
  119. DebugPrintEx(DEBUG_WRN, _T("Failed to FreeLibrary() for Msi, ec=%ld."), dwReturn);
  120. }
  121. return dwReturn;
  122. }
  123. ///////////////////////////////////////////////////////////////////////////////////////
  124. // Function:
  125. // WasSBS2000FaxServerInstalled
  126. //
  127. // Purpose:
  128. // This function checks if the SBS2000 fax service was installed
  129. // before the upgrade to .NET Server/Bobcat happened.
  130. //
  131. // Params:
  132. // BOOL* pbSBSServer - out param to report to the caller
  133. // if the fax server was installed
  134. //
  135. // Return Value:
  136. // ERROR_SUCCESS - in case of success
  137. // Win32 Error code - in case of failure
  138. //
  139. // Author:
  140. // Mooly Beery (MoolyB) 13-Dec-2001
  141. //////////////////////////////////////////////////////////////////////////////////////
  142. DWORD WasSBS2000FaxServerInstalled(bool *pbSBSServer)
  143. {
  144. DWORD dwRes = ERROR_SUCCESS;
  145. HKEY hKey = NULL;
  146. DWORD dwInstalled = 0;
  147. DEBUG_FUNCTION_NAME(TEXT("WasSBS2000FaxServerInstalled"))
  148. (*pbSBSServer) = FALSE;
  149. // try to open HKLM\\Software\\Microsoft\\SharedFaxBackup
  150. hKey = OpenRegistryKey(HKEY_LOCAL_MACHINE,REGKEY_SBS2000_FAX_BACKUP,FALSE,KEY_READ);
  151. if (hKey==NULL)
  152. {
  153. DebugPrintEx(DEBUG_MSG,_T("HKLM\\Software\\Microsoft\\SharedFax does not exist, SBS2000 server was not installed"));
  154. goto exit;
  155. }
  156. else
  157. {
  158. DebugPrintEx(DEBUG_MSG,_T("HKLM\\Software\\Microsoft\\SharedFax does exists, SBS2000 server was installed"));
  159. (*pbSBSServer) = TRUE;
  160. goto exit;
  161. }
  162. exit:
  163. if (hKey)
  164. {
  165. RegCloseKey(hKey);
  166. }
  167. return dwRes;
  168. }