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.

83 lines
1.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: snaphelp.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _ATLSNAPHELP_H_
  11. #define _ATLSNAPHELP_H_
  12. //
  13. // Include files
  14. //
  15. #include "htmlhelp.h"
  16. //
  17. // Allocates memory for a string, copies the string,
  18. // and returns it to the caller. Throws exceptions.
  19. //
  20. inline LPOLESTR CoTaskDupString( LPOLESTR pszInput )
  21. {
  22. USES_CONVERSION;
  23. LPOLESTR pszOut = NULL;
  24. //
  25. // We throw an exception if the following allocation fails.
  26. //
  27. pszOut = (LPOLESTR) CoTaskMemAlloc( ( wcslen( pszInput ) + 1 ) * sizeof( OLECHAR ) );
  28. if ( pszOut == NULL )
  29. throw;
  30. wcscpy( pszOut, pszInput );
  31. return( pszOut );
  32. };
  33. template <class T>
  34. class ATL_NO_VTABLE ISnapinHelpImpl : public ISnapinHelp
  35. {
  36. public:
  37. //
  38. // Returns a helpfile name using the ATL module name
  39. // and appending the appropriate suffix onto the filename.
  40. //
  41. STDMETHOD( GetHelpTopic )( LPOLESTR* lpCompiledHelpFile )
  42. {
  43. _ASSERT( lpCompiledHelpFile != NULL );
  44. USES_CONVERSION;
  45. HRESULT hr = E_FAIL;
  46. TCHAR szPath[ _MAX_PATH * 2 ];
  47. TCHAR szDrive[ _MAX_DRIVE * 2 ], szDir[ _MAX_DIR * 2 ];
  48. TCHAR szName[ _MAX_FNAME * 2 ], szExt[ _MAX_EXT ];
  49. try
  50. {
  51. //
  52. // Get the module filename.
  53. //
  54. if ( GetModuleFileName( _Module.GetModuleInstance(), szPath, sizeof( szPath ) / sizeof( TCHAR ) ) == NULL )
  55. throw;
  56. //
  57. // Split the given path.
  58. //
  59. _tsplitpath( szPath, szDrive, szDir, szName, szExt );
  60. _tmakepath( szPath, szDrive, szDir, szName, _T( ".chm" ) );
  61. //
  62. // Allocate the string and return it.
  63. *lpCompiledHelpFile = CoTaskDupString( T2W( szPath ) );
  64. hr = S_OK;
  65. }
  66. catch( ... )
  67. {
  68. }
  69. return( hr );
  70. }
  71. };
  72. #endif