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.

112 lines
3.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: msimodul.h
  8. //
  9. //--------------------------------------------------------------------------
  10. // msimodl.h : header file for class CMsiModule
  11. //
  12. #ifndef __MSIMODL_H__
  13. #define __MSIMODL_H__
  14. #include <msi.h>
  15. #include <msiquery.h>
  16. class CMsiModule
  17. {
  18. typedef UINT (*EnumQualCompFncPtr)(LPTSTR, DWORD, LPTSTR, DWORD*, LPTSTR, DWORD*);
  19. typedef UINT (*ProvideQualCompFncPtr)(LPCTSTR, LPCTSTR, DWORD, LPTSTR, DWORD*);
  20. typedef UINT (*LocateCompFncPtr)(LPCTSTR, LPTSTR, DWORD*);
  21. public:
  22. CMsiModule(void) : hMsiDll(NULL), pfnEnumQualComp(NULL), pfnProvideQualComp(NULL)
  23. {
  24. hMsiDll = LoadLibrary(TEXT("msi.dll"));
  25. if (hMsiDll != NULL)
  26. {
  27. #ifdef _UNICODE
  28. pfnEnumQualComp = reinterpret_cast<EnumQualCompFncPtr>
  29. (GetProcAddress(hMsiDll, "MsiEnumComponentQualifiersW"));
  30. ASSERT(pfnEnumQualComp != NULL);
  31. pfnProvideQualComp = reinterpret_cast<ProvideQualCompFncPtr>
  32. (GetProcAddress(hMsiDll, "MsiProvideQualifiedComponentW"));
  33. ASSERT(pfnProvideQualComp != NULL);
  34. pfnLocateComp = reinterpret_cast<LocateCompFncPtr>
  35. (GetProcAddress(hMsiDll, "MsiLocateComponentW"));
  36. ASSERT(pfnLocateComp != NULL);
  37. #else
  38. pfnEnumQualComp = reinterpret_cast<EnumQualCompFncPtr>
  39. (GetProcAddress(hMsiDll, "MsiEnumComponentQualifiersA"));
  40. ASSERT(pfnEnumQualComp != NULL);
  41. pfnProvideQualComp = reinterpret_cast<ProvideQualCompFncPtr>
  42. (GetProcAddress(hMsiDll, "MsiProvideQualifiedComponentA"));
  43. ASSERT(pfnProvideQualComp != NULL);
  44. pfnLocateComp = reinterpret_cast<LocateCompFncPtr>
  45. (GetProcAddress(hMsiDll, "MsiLocateComponentA"));
  46. ASSERT(pfnLocateComp != NULL);
  47. #endif // _UNICODE
  48. }
  49. }
  50. ~CMsiModule(void) { if (hMsiDll != NULL) FreeLibrary(hMsiDll); }
  51. BOOL IsPresent(void) { return (hMsiDll != NULL); }
  52. UINT EnumComponentQualifiers( LPTSTR szComponent, DWORD iIndex,
  53. LPTSTR lpQualifierBuf, DWORD *pcchQualifierBuf,
  54. LPTSTR lpApplicationDataBuf, DWORD *pcchApplicationDataBuf)
  55. {
  56. if (pfnEnumQualComp == NULL)
  57. return ERROR_CALL_NOT_IMPLEMENTED;
  58. return pfnEnumQualComp(szComponent, iIndex, lpQualifierBuf, pcchQualifierBuf,
  59. lpApplicationDataBuf, pcchApplicationDataBuf);
  60. }
  61. UINT ProvideQualifiedComponent( LPCTSTR szComponent, LPCTSTR szQualifier, DWORD dwInstallMode,
  62. LPTSTR lpPathBuf, DWORD *pcchPathBuf)
  63. {
  64. if (pfnProvideQualComp == NULL)
  65. return ERROR_CALL_NOT_IMPLEMENTED;
  66. return pfnProvideQualComp(szComponent, szQualifier, dwInstallMode, lpPathBuf, pcchPathBuf);
  67. }
  68. UINT LocateComponent( LPCTSTR szComponent, LPTSTR lpPathBuf, DWORD *pcchPathBuf)
  69. {
  70. if (pfnLocateComp == NULL)
  71. return ERROR_CALL_NOT_IMPLEMENTED;
  72. return pfnLocateComp(szComponent, lpPathBuf, pcchPathBuf);
  73. }
  74. private:
  75. HMODULE hMsiDll;
  76. EnumQualCompFncPtr pfnEnumQualComp;
  77. ProvideQualCompFncPtr pfnProvideQualComp;
  78. LocateCompFncPtr pfnLocateComp;
  79. };
  80. CMsiModule& MsiModule()
  81. {
  82. static CMsiModule MsiModuleInstance;
  83. return MsiModuleInstance;
  84. }
  85. #endif // __MSIMODL_H__