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.

89 lines
2.4 KiB

  1. // Copyright (C) 1997-1998 Microsoft Corporation. All rights reserved.
  2. #include "header.h"
  3. #include <msi.h>
  4. extern HMODULE g_hmodMSI; // msi.dll module handle
  5. static const char txtMsiProvideQualifiedComponent[] = "MsiProvideQualifiedComponentA";
  6. static const char txtMsiDll[] = "Msi.dll";
  7. UINT (WINAPI *pMsiProvideQualifiedComponent)(LPCSTR szCategory, LPCSTR szQualifier, DWORD dwInstallMode, LPSTR lpPathBuf, DWORD *pcchPathBuf);
  8. /***************************************************************************
  9. FUNCTION: FindDarwinURL
  10. PURPOSE: Given a GUID and CHM filename, find the full path to the
  11. CHM file using Darwin.
  12. PARAMETERS:
  13. pszGUID
  14. pszChmFile
  15. cszResult
  16. RETURNS:
  17. COMMENTS:
  18. MODIFICATION DATES:
  19. 01-Dec-1997 [ralphw]
  20. ***************************************************************************/
  21. BOOL FindDarwinURL(PCSTR pszGUID, PCSTR pszChmFile, CStr* pcszResult)
  22. {
  23. if (!pMsiProvideQualifiedComponent) {
  24. if (!g_hmodMSI) {
  25. g_hmodMSI = LoadLibrary(txtMsiDll);
  26. ASSERT_COMMENT(g_hmodMSI, "Cannot load msi.dll");
  27. if (!g_hmodMSI)
  28. return FALSE;
  29. }
  30. (FARPROC&) pMsiProvideQualifiedComponent = GetProcAddress(g_hmodMSI,
  31. txtMsiProvideQualifiedComponent);
  32. ASSERT_COMMENT(pMsiProvideQualifiedComponent, "Cannot find the MsiProvideQualifiedComponent in msi.dll");
  33. if (!pMsiProvideQualifiedComponent)
  34. return FALSE;
  35. }
  36. char szPath[MAX_PATH];
  37. DWORD cb = sizeof(szPath);
  38. // Office passes in the LCID on the end of the GUID. Ick. Parse out the LCID.
  39. CStr szGUID(pszGUID) ;
  40. CStr szLCID;
  41. // Check last character for the ending bracket.
  42. int len = szGUID.strlen() ;
  43. if (szGUID.psz[len-1] != '}')
  44. {
  45. // No bracket. Assume we have a LCID.
  46. char* pLcid = strchr(szGUID.psz, '}') ;
  47. if (pLcid)
  48. {
  49. // Copy the LCID.
  50. pLcid++ ;
  51. szLCID = pLcid;
  52. // Remove from the guid.
  53. *pLcid = '\0' ;
  54. }
  55. }
  56. else
  57. {
  58. ASSERT(0) ;
  59. return FALSE ;
  60. }
  61. // Prepend the LCID to the CHM file name.
  62. CStr szQualifier ;
  63. szQualifier = szLCID.psz ;
  64. szQualifier += "\\" ;
  65. szQualifier += pszChmFile ;
  66. // Ask for the file.
  67. if (pMsiProvideQualifiedComponent(szGUID, szQualifier/*pszChmFile*/, INSTALLMODE_EXISTING,
  68. szPath, &cb) != ERROR_SUCCESS)
  69. return FALSE;
  70. *pcszResult = szPath;
  71. return TRUE;
  72. }