Download presentation
Presentation is loading. Please wait.
PublishDwain Davis Modified over 9 years ago
1
Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation
2
Agenda Office 2000 demand install demo Quick refresher on architecture Installer API overview Install sample application - MsiSpy tool Examine sample application code in debugger Questions
3
Demo Office 2000 demand install
4
Architecture Installer Package and files File System Registry Applications Shell, COM, and App MGMT Client Active Directory Windows installer API Windows installer service ConfigData Configuration data Tracks state of installed apps Tracks state of installed apps Service built into OS Service on Windows NT Service on Windows NT Performs all install operations Performs all install operations API Install and configure packages and features Install and configure packages and features Query machine state Query machine state Build packages Build packages Package format Describes required state Describes required state
5
Component 1 (WordCore) Component 3 (ExcelCore) Component 2 (MS Speller) Features, Components, Resources, And Entry Points Product(Office) Feature 2 (Excel) Feature 1 (Word) Entry Point (.doc) (Shortcut) (.xls) (Shortcut) (CLSID) Resource (Registry Key) Resource(winword.exe) Resource Resource(excel.exe) Resource Resource(Mssp.dll) Feature 3 (Word Speller) Feature 4 (Excel Speller)
6
An Installer-Aware App Feature/component definitions in code Get product ID at app initialization Enable UI based on feature state MsiQueryFeatureState MsiQueryFeatureState Install features as they are used MsiUseFeature (“golden pyramid”) MsiUseFeature (“golden pyramid”) Error-trapping approach Error-trapping approach Use installer to find paths MsiProvideComponent MsiProvideComponent MsiProvideQualifiedComponent MsiProvideQualifiedComponent
7
TCHAR szCoreComponent[]= TEXT(" {5CB2D5F5-19DD-11d1-9A9D-006097C4E489} "); if (MsiGetProductCode( szCoreComponent, vszProductCode) != ERROR_SUCCESS) return FALSE; Installer Datatypes Product ID Product code - a string GUID Can hardcode this or hardcode “core component ID” (e.g. For your EXE) Can hardcode this or hardcode “core component ID” (e.g. For your EXE) Depends on whether you ship multiple products with your application or not Depends on whether you ship multiple products with your application or not Many installer APIs need product code Many installer APIs need product code
8
Installer Datatypes Feature/Component IDs Feature IDs are text strings Limited to MAX_FEATURE_CHARS Limited to MAX_FEATURE_CHARS Internal names Internal names Evaluated relative to product code Evaluated relative to product code Component IDs are GUID strings Global across all products Global across all products Components have a key file -- use MsiGetComponentPath or MsiProvideComponent to get path to the component key file Components have a key file -- use MsiGetComponentPath or MsiProvideComponent to get path to the component key file Component IDs change when components change in incompatible ways Component IDs change when components change in incompatible ways
9
Gives “installed state” of a feature, product or component MsiQueryFeatureState to obtain for a feature MsiQueryFeatureState to obtain for a feature Example: speller Example: speller Remember that components are only installed as part of a feature, so feature INSTALLSTATE is what is interesting Remember that components are only installed as part of a feature, so feature INSTALLSTATE is what is interesting INSTALLSTATE_LOCAL INSTALLSTATE_SOURCE INSTALLSTATE_ABSENT Feature is not available to be installed Feature is not available to be installed Installer Datatypes INSTALLSTATE
10
INSTALLSTATE_ADVERTISED Feature is not installed, but can be installed Feature is not installed, but can be installed Use MsiConfigureFeatureState to install Use MsiConfigureFeatureState to install INSTALLSTATE_DEFAULT installs the feature “normally” (either local or source) INSTALLSTATE_DEFAULT installs the feature “normally” (either local or source) INSTALLSTATE_BROKEN Feature is installed, but not intact Feature is installed, but not intact INSTALLSTATE_SOURCEABSENT Feature is installed to run from source but the source is missing (e.g., CD missing, net down) Feature is installed to run from source but the source is missing (e.g., CD missing, net down) Installer Datatypes INSTALLSTATE
11
How much work installer should do to provide a feature or component MsiUseFeatureEx MsiUseFeatureEx MsiProvideComponent MsiProvideComponent MsiProvideQualifiedComponent MsiProvideQualifiedComponent INSTALLMODE_DEFAULT INSTALLMODE_EXISTING INSTALLMODE_NODETECTION Save one GetFileAttributesEx call Save one GetFileAttributesEx call Installer Datatypes INSTALLMODE
12
Used when repairing a feature Can use in place of INSTALLMODE flags Can use in place of INSTALLMODE flags MsiReinstallFeature MsiReinstallFeature MsiReinstallProduct MsiReinstallProduct REINSTALLMODE_FILEMISSING REINSTALLMODE_FILEEXACT REINSTALLMODE_FILEVERIFY REINSTALLMODE_MACHINEDATA REINSTALLMODE_USERDATA Installer Datatypes REINSTALLMODE
13
Using Features MsiUseFeature when a feature is used Increments feature’s usage count (obtain with MsiGetFeatureUsage ) Increments feature’s usage count (obtain with MsiGetFeatureUsage ) If feature not installed, install it! Use MsiConfigureFeature to install Use MsiConfigureFeature to install MsiUseFeatureEx combines these. If needed, get path to a component key file using MsiGetComponentPath For use with LoadLibrary, CreateFile, etc. For use with LoadLibrary, CreateFile, etc.
14
Resiliency What if LoadLibrary fails? Features can be broken User deletes file (LoadLibrary fails) User deletes file (LoadLibrary fails) User removes necessary registry info (CoCreateInstance fails) User removes necessary registry info (CoCreateInstance fails) Just offer to reinstall the feature! UINT MsiReinstallFeature( LPCTSTR szProduct, // product code LPCTSTR szFeature, // feature ID LPCTSTR dwReinstallMode);
15
Performance Tip Installer will verify feature install states Registry lookups + one GetFileAttributes call per feature component Registry lookups + one GetFileAttributes call per feature component For very commonly used features (e.g., application boot), you can first just look in the “usual place” (e.g., app directory) If LoadLibrary fails, fall back on installer API to find and/or reinstall feature If LoadLibrary fails, fall back on installer API to find and/or reinstall feature Lose feature usage metrics, some safety Lose feature usage metrics, some safety
16
Published Components Also called “Qualified Components” MsiProvideQualifiedComponent MsiProvideQualifiedComponent MsiEnumComponentQualifiers MsiEnumComponentQualifiers Very flexible scheme for managing lists of components Examples: text converters, wizards, templates, any per-language component Examples: text converters, wizards, templates, any per-language component Flexible way of sharing features across products without hard coding component IDs
17
UINT MsiProvideQualifiedComponent( LPCTSTR szCategory, // category GUID LPCTSTR szQualifier, // qualifier string DWORD dwInstallMode, // the install mode LPTSTR lpPathBuf, // in/out path, // NULL if unneeded DWORD *pcchPathBuf); // in/out Published Components Category GUID not a component ID! Think of as “array name” Think of as “array name” Array index is szQualifier File Type, LCID, etc. File Type, LCID, etc.
18
Published Components {5CB2D5F5-19DD-11d1-9A9D-006097C4E489} “1033”, “English” “1036”, “French” “1031”, “German” {5CB2D5F5-19DD-11d1-9A9D-006097C4E500} {5CB2D5F5-19DD-11d1-9A9D-006097C4E501} {5CB2D5F5-19DD-11d1-9A9D-006097C4E502} APPDEU.DLL APPFRA.DLL APPENU.DLL
19
Published Components UINT MsiEnumComponentQualifiers( LPCTSTR szCategory, // category GUID LPCTSTR szCategory, // category GUID DWORD iIndex, // 0-based index DWORD iIndex, // 0-based index LPTSTR szQualifier, // qualifier string LPTSTR szQualifier, // qualifier string DWORD *pcchQualifier // in/out DWORD *pcchQualifier // in/out LPTSTR szAppData, // AppData string LPTSTR szAppData, // AppData string DWORD *pcchAppData); // in/out DWORD *pcchAppData); // in/out Use to populate listbox Office 2000: list of languages supported Office 2000: list of languages supported AppData is intended for UI Office 2000: user-readable language name Office 2000: user-readable language name
20
Shell Support “Installer Token”: New form of Shell shortcut on Internet Explorer 4.01 SP 1 Shell, Windows 98 and Windows NT ® 5.0 Encapsulates Product/Feature/Component Encapsulates Product/Feature/Component Can live in Start menu or on Desktop Shell will detect that shortcut is an Installer Descriptor and invoke installer to provide the component path Free install on demand for apps Note: only installs product’s main feature Note: only installs product’s main feature
21
COM Support “Installer Descriptor” can be used in COM registry on Windows NT 5.0 Same format as Shell shortcut Same format as Shell shortcut OLE will invoke installer to provide the component path Free install on demand for COM components Note: only installs target feature Note: only installs target feature
22
Demo MsiSpy sample
23
Next Steps Add resiliency to your application Use Published Components to share features across applications Use Windows installer to Make “run from network server” free Make “run from network server” free Make automated deployment easy Make automated deployment easy Allow users/administrators to tailor application install size without losing any functionality Allow users/administrators to tailor application install size without losing any functionality Use the installer for your application!
24
Call To Action Empower your applications for management! Separate user and machine data Separate user and machine data See MGMT 001 See MGMT 001 Policy Enable Your Application Policy Enable Your Application See MGMT 001, MGMT 006 See MGMT 001, MGMT 006 Create a Windows installer package Create a Windows installer package See MGMT 003, MGMT 004 See MGMT 003, MGMT 004 Leverage the Windows installer API Leverage the Windows installer API See MGMT 005 See MGMT 005 Leverage Active Directory for Application Data Leverage Active Directory for Application Data See DS 05, DS 06 See DS 05, DS 06
25
Windows NT 5.0 Logo Leverage your investment in Windows installer Install/uninstall is top concern among customers Install/uninstall is top concern among customers 1 of 4 key areas of the new Windows NT 5.0 logo 1 of 4 key areas of the new Windows NT 5.0 logo Follow up info Draft requirements: Draft requirements: On the conference DVD On the conference DVD www.microsoft.com/windows/winlogo/developer www.microsoft.com/windows/winlogo/developer Feedback: logotalk@microsoft.com by 11/15 Feedback: logotalk@microsoft.com by 11/15
26
Questions And Answers
28
Product Codes
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.