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.

133 lines
3.7 KiB

  1. // msinfo32.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To build a separate proxy/stub DLL,
  4. // run nmake -f msinfo32ps.mk in the project directory.
  5. #include "stdafx.h"
  6. #include "resource.h"
  7. #include <initguid.h>
  8. #include "msinfo32.h"
  9. #include "msinfo32_i.c"
  10. #include "MSInfo.h"
  11. //#include "WhqlProv.h"
  12. //#ifdef MSINFO_INCLUDE_PROVIDER
  13. #include "WhqlObj.h"
  14. //#endif
  15. #include "MSPID.h"
  16. CComModule _Module;
  17. BEGIN_OBJECT_MAP(ObjectMap)
  18. OBJECT_ENTRY(CLSID_MSInfo, CMSInfo)
  19. //#ifdef MSINFO_INCLUDE_PROVIDER
  20. OBJECT_ENTRY(CLSID_WhqlObj, CWhqlObj)
  21. //#endif
  22. OBJECT_ENTRY(CLSID_MSPID, CMSPID)
  23. END_OBJECT_MAP()
  24. class CMsinfo32App : public CWinApp
  25. {
  26. public:
  27. // Overrides
  28. // ClassWizard generated virtual function overrides
  29. //{{AFX_VIRTUAL(CMsinfo32App)
  30. public:
  31. virtual BOOL InitInstance();
  32. virtual int ExitInstance();
  33. //}}AFX_VIRTUAL
  34. //{{AFX_MSG(CMsinfo32App)
  35. // NOTE - the ClassWizard will add and remove member functions here.
  36. // DO NOT EDIT what you see in these blocks of generated code !
  37. //}}AFX_MSG
  38. DECLARE_MESSAGE_MAP()
  39. };
  40. BEGIN_MESSAGE_MAP(CMsinfo32App, CWinApp)
  41. //{{AFX_MSG_MAP(CMsinfo32App)
  42. // NOTE - the ClassWizard will add and remove mapping macros here.
  43. // DO NOT EDIT what you see in these blocks of generated code!
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. CMsinfo32App theApp;
  47. BOOL CMsinfo32App::InitInstance()
  48. {
  49. AfxInitRichEdit();
  50. _Module.Init(ObjectMap, m_hInstance, &LIBID_MSINFO32Lib);
  51. return CWinApp::InitInstance();
  52. }
  53. int CMsinfo32App::ExitInstance()
  54. {
  55. _Module.Term();
  56. return CWinApp::ExitInstance();
  57. }
  58. /////////////////////////////////////////////////////////////////////////////
  59. // Used to determine whether the DLL can be unloaded by OLE
  60. STDAPI DllCanUnloadNow(void)
  61. {
  62. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  63. return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
  64. }
  65. /////////////////////////////////////////////////////////////////////////////
  66. // Returns a class factory to create an object of the requested type
  67. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  68. {
  69. return _Module.GetClassObject(rclsid, riid, ppv);
  70. }
  71. /////////////////////////////////////////////////////////////////////////////
  72. // DllRegisterServer - Adds entries to the system registry
  73. STDAPI DllRegisterServer(void)
  74. {
  75. // Whistler bug 301288
  76. //
  77. // We need to add an entry under the HKCR\msinfo.document registry key
  78. // to enable MUI retrieval of the file description. The entry is a
  79. // value, and should have the form:
  80. //
  81. // "FriendlyTypeName"="@<dllpath\dllname>, -<resID>"
  82. //
  83. // Note - since the resource for the string is in this DLL, it seems
  84. // appropriate to create this value here. The overall key for
  85. // msinfo.document is created (for now) by registering msinfo32.dll.
  86. // The important point is that we shouldn't assume it exists.
  87. CRegKey regkey;
  88. if (ERROR_SUCCESS == regkey.Create(HKEY_CLASSES_ROOT, _T("msinfo.document")))
  89. {
  90. TCHAR szModule[MAX_PATH + 1];
  91. ::ZeroMemory((PVOID)szModule, sizeof(szModule));
  92. if (::GetModuleFileName(::GetModuleHandle(_T("msinfo.dll")), szModule, MAX_PATH))
  93. {
  94. CString strValue;
  95. strValue.Format(_T("@%s,-%d"), szModule, IDS_DOCDESCRIPTION);
  96. regkey.SetValue(strValue, _T("FriendlyTypeName"));
  97. }
  98. }
  99. // registers object, typelib and all interfaces in typelib
  100. return _Module.RegisterServer(TRUE);
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. // DllUnregisterServer - Removes entries from the system registry
  104. STDAPI DllUnregisterServer(void)
  105. {
  106. return _Module.UnregisterServer(TRUE);
  107. }