home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / Chip_2001-06_cd1.bin / zkuste / vbasic / Data / Utility / MSISDK15.msi / Tutorial.cpp < prev    next >
C/C++ Source or Header  |  2000-10-05  |  3KB  |  102 lines

  1. #if 0  // makefile definitions
  2. DESCRIPTION = Microsoft Installer for Windows\256 Test
  3. MODULENAME = tutorial
  4. FILEVERSION = Msi
  5. LINKLIBS = shell32.lib
  6. ENTRY = LaunchTutorial
  7. !include "..\TOOLS\MsiTool.mak"
  8. !if 0  #nmake skips the rest of this file
  9. #endif // end of makefile definitions
  10.  
  11. // Required headers
  12. #define WINDOWS_LEAN_AND_MEAN  // faster compile
  13. #include <windows.h>
  14. #ifndef RC_INVOKED    // start of source code
  15.  
  16. #include "msiquery.h"
  17. #include <tchar.h>   // define UNICODE=1 on nmake command line to build UNICODE
  18. #include <shellapi.h>
  19.  
  20. //+-------------------------------------------------------------------------
  21. //
  22. //  Microsoft Windows
  23. //
  24. //  Copyright (C) Microsoft Corporation, 2000
  25. //
  26. //  File:       tutorial.cpp
  27. //
  28. //--------------------------------------------------------------------------
  29.  
  30. //-----------------------------------------------------------------------------------------
  31. //
  32. // BUILD Instructions
  33. //
  34. // notes:
  35. //    - SDK represents the full path to the install location of the
  36. //     Windows Installer SDK
  37. //
  38. // Using NMake:
  39. //        %vcbin%\nmake -f tutorial.cpp include="%include;SDK\Include" lib="%lib%;SDK\Lib"
  40. //
  41. // Using MsDev:
  42. //        1. Create a new Win32 DLL project
  43. //      2. Add tutorial.cpp to the project
  44. //      3. Add SDK\Include and SDK\Lib directories on the Tools\Options Directories tab
  45. //      4. Add msi.lib to the library list in the Project Settings dialog
  46. //          (in addition to the standard libs included by MsDev)
  47. //
  48. //------------------------------------------------------------------------------------------
  49.  
  50. //////////////////////////////////////////////////////////////////////////////
  51. // LaunchTutorial
  52. //
  53. // Launches a installed file at the end of setup
  54. //
  55. UINT __stdcall LaunchTutorial(MSIHANDLE hInstall)
  56. {
  57.     UINT uiStat = 0;
  58.     const TCHAR szTutorialFileKey[] = TEXT("[#Tutorial]");
  59.     PMSIHANDLE hRecTutorial = ::MsiCreateRecord(1);
  60.     ::MsiRecordSetString(hRecTutorial, 0, szTutorialFileKey);
  61.  
  62.     // determine buffer size
  63.     DWORD dwPath = 0;
  64.     ::MsiFormatRecord(hInstall, hRecTutorial, TEXT(""), &dwPath);
  65.     TCHAR* szPath = new TCHAR[++dwPath];
  66.     // determine path to installed file
  67.     if (ERROR_SUCCESS != ::MsiFormatRecord(hInstall, hRecTutorial, szPath, &dwPath))
  68.     {
  69.         if (szPath)
  70.             delete [] szPath;
  71.         return ERROR_INSTALL_FAILURE;
  72.     }
  73.  
  74.     // set up ShellExecute structure
  75.     // file is the full path to the installed file
  76.     SHELLEXECUTEINFO sei;
  77.     sei.fMask = SEE_MASK_FLAG_NO_UI; // don't show error UI, we'll just silently fail
  78.     sei.hwnd = 0;
  79.     sei.lpVerb = NULL; // use default verb, typically open
  80.     sei.lpFile = szPath;
  81.     sei.lpParameters = NULL;
  82.     sei.lpDirectory = NULL;
  83.     sei.nShow = SW_SHOWNORMAL;
  84.     sei.cbSize = sizeof(sei);
  85.  
  86.     // spawn the browser to display HTML tutorial
  87.     BOOL fSuccess = ShellExecuteEx(&sei);
  88.  
  89.     if (szPath)
  90.         delete [] szPath;
  91.  
  92.     return (fSuccess) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
  93. }
  94.  
  95. #else // RC_INVOKED, end of source code, start of resources
  96. // resource definition go here
  97.  
  98. #endif // RC_INVOKED
  99. #if 0 
  100. !endif // makefile terminator
  101. #endif
  102.