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.

58 lines
1.2 KiB

  1. #ifndef _ATLSNAPHELP_H_
  2. #define _ATLSNAPHELP_H_
  3. //
  4. // Include files
  5. //
  6. #include "htmlhelp.h"
  7. #include "expand.h"
  8. //
  9. // Allocates memory for a string, copies the string,
  10. // and returns it to the caller. Throws exceptions.
  11. //
  12. inline LPOLESTR CoTaskDupString( LPOLESTR pszInput )
  13. {
  14. USES_CONVERSION;
  15. LPOLESTR pszOut = NULL;
  16. //
  17. // We throw an exception if the following allocation fails.
  18. //
  19. pszOut = (LPOLESTR) CoTaskMemAlloc( ( wcslen( pszInput ) + 1 ) * sizeof( OLECHAR ) );
  20. if ( pszOut == NULL )
  21. throw;
  22. wcscpy( pszOut, pszInput );
  23. return( pszOut );
  24. };
  25. template <class T>
  26. class ATL_NO_VTABLE ISnapinHelpImpl : public ISnapinHelp
  27. {
  28. public:
  29. // get the dkms help file location and returns it
  30. STDMETHOD( GetHelpTopic )( LPOLESTR* lpCompiledHelpFile )
  31. {
  32. _ASSERT( lpCompiledHelpFile != NULL );
  33. USES_CONVERSION;
  34. HRESULT hr = E_FAIL;
  35. TCHAR szPath[ _MAX_PATH * 2 ];
  36. // this is where the dkms help file is stored
  37. wcscpy(szPath, L"%systemroot%\\help\\defrag.chm");
  38. // expand out the %systemroot% variable
  39. ExpandEnvVars(szPath);
  40. // Allocate the string and return it.
  41. *lpCompiledHelpFile = CoTaskDupString( T2W( szPath ) );
  42. hr = S_OK;
  43. return( hr );
  44. }
  45. };
  46. #endif