creating dynamic and robust applications with the windows ® installer mike kelly lead software...

28
Creating Dynamic And Creating Dynamic And Robust Applications Robust Applications With The Windows With The Windows ® ® Installer Installer Mike Kelly Mike Kelly Lead Software Design Engineer Lead Software Design Engineer Microsoft Office TCO Team Microsoft Office TCO Team Microsoft Corporation Microsoft Corporation

Upload: dwain-davis

Post on 22-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Creating Dynamic And Creating Dynamic And Robust Applications With Robust Applications With The WindowsThe Windows®® Installer Installer

Mike KellyMike KellyLead Software Design EngineerLead Software Design EngineerMicrosoft Office TCO TeamMicrosoft Office TCO TeamMicrosoft CorporationMicrosoft Corporation

Page 2: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

AgendaAgenda

Office 2000 demand install demoOffice 2000 demand install demo Quick refresher on architectureQuick refresher on architecture Installer API overviewInstaller API overview Install sample application - MsiSpy toolInstall sample application - MsiSpy tool Examine sample application code Examine sample application code

in debuggerin debugger QuestionsQuestions

Page 3: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

DemoDemo

Office 2000 demand installOffice 2000 demand install

Page 4: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

ArchitectureArchitecture

Installer Package Installer Package and filesand files

File SystemFile System RegistryRegistry

ApplicationsApplications

Shell, COM, Shell, COM, and App MGMT and App MGMT

ClientClient

Active Active DirectoryDirectory

Windows installer APIWindows installer API

Windows installer Windows installer serviceservice

ConfigConfigDataData

Configuration dataConfiguration data Tracks state of Tracks state of

installed appsinstalled apps

Service built into OSService built into OS Service on Windows NTService on Windows NT Performs all Performs all

install operationsinstall operations

APIAPI Install and configure Install and configure

packages and featurespackages and features Query machine stateQuery machine state Build packagesBuild packages

Package formatPackage format Describes required stateDescribes required state

Page 5: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Component 1Component 1(WordCore)(WordCore)

Component 3Component 3(ExcelCore)(ExcelCore)

Component 2Component 2(MS Speller)(MS Speller)

Features, Components, Features, Components, Resources, And Entry PointsResources, And Entry Points

ProductProduct(Office)(Office)

Feature 2Feature 2(Excel)(Excel)

Feature 1Feature 1(Word)(Word)

Entry PointEntry Point(.doc)(.doc)

Entry PointEntry Point(Shortcut)(Shortcut)

Entry PointEntry Point(.xls)(.xls)

Entry PointEntry Point(Shortcut)(Shortcut)

Entry PointEntry Point(CLSID)(CLSID)

ResourceResource(Registry Key)(Registry Key)

ResourceResource(winword.exe)(winword.exe)

ResourceResource(Registry Key)(Registry Key)

ResourceResource(excel.exe)(excel.exe)

ResourceResource(Registry Key)(Registry Key)

ResourceResource(Mssp.dll)(Mssp.dll)

Feature 3Feature 3(Word Speller)(Word Speller)

Feature 4Feature 4(Excel Speller)(Excel Speller)

Page 6: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

An Installer-Aware AppAn Installer-Aware App

Feature/component definitions in codeFeature/component definitions in code Get product ID at app initializationGet product ID at app initialization Enable UI based on feature stateEnable UI based on feature state

MsiQueryFeatureStateMsiQueryFeatureState Install features as they are usedInstall features as they are used

MsiUseFeature (“golden pyramid”) MsiUseFeature (“golden pyramid”) Error-trapping approachError-trapping approach

Use installer to find pathsUse installer to find paths MsiProvideComponentMsiProvideComponent MsiProvideQualifiedComponentMsiProvideQualifiedComponent

Page 7: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

TCHAR szCoreComponent[] = TEXT("{5CB2D5F5-19DD-11d1-9A9D-006097C4E489}");

if (MsiGetProductCode( szCoreComponent,vszProductCode) != ERROR_SUCCESS)return FALSE;

Installer DatatypesInstaller DatatypesProduct IDProduct ID

Product code - a string GUIDProduct code - a string GUID Can hardcode this or hardcode “core Can hardcode this or hardcode “core

component ID” (e.g. For your EXE)component ID” (e.g. For your EXE) Depends on whether you ship multiple Depends on whether you ship multiple

products with your application or notproducts with your application or not Many installer APIs need product codeMany installer APIs need product code

Page 8: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Installer DatatypesInstaller DatatypesFeature/Component IDsFeature/Component IDs

Feature IDs are text stringsFeature IDs are text strings Limited to MAX_FEATURE_CHARSLimited to MAX_FEATURE_CHARS Internal namesInternal names Evaluated relative to product codeEvaluated relative to product code

Component IDs are GUID stringsComponent IDs are GUID strings Global across all productsGlobal across all products Components have a key file -- use Components have a key file -- use

MsiGetComponentPath or MsiProvideComponent MsiGetComponentPath or MsiProvideComponent to get path to the component key fileto get path to the component key file

Component IDs change when components Component IDs change when components change in incompatible wayschange in incompatible ways

Page 9: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Gives “installed state” of a feature, product Gives “installed state” of a feature, product or componentor component MsiQueryFeatureState MsiQueryFeatureState to obtain for a featureto obtain for a feature Example: spellerExample: speller Remember that components are Remember that components are onlyonly installed as installed as

part of a feature, so feature INSTALLSTATE is part of a feature, so feature INSTALLSTATE is what is interestingwhat is interesting

INSTALLSTATE_LOCALINSTALLSTATE_LOCAL INSTALLSTATE_SOURCEINSTALLSTATE_SOURCE INSTALLSTATE_ABSENTINSTALLSTATE_ABSENT

Feature is not available to be installedFeature is not available to be installed

Installer DatatypesInstaller DatatypesINSTALLSTATEINSTALLSTATE

Page 10: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

INSTALLSTATE_ADVERTISEDINSTALLSTATE_ADVERTISED Feature is not installed, but can be installedFeature is not installed, but can be installed Use Use MsiConfigureFeatureStateMsiConfigureFeatureState to install to install

INSTALLSTATE_DEFAULT installs the feature INSTALLSTATE_DEFAULT installs the feature “normally” (either local or source)“normally” (either local or source)

INSTALLSTATE_BROKENINSTALLSTATE_BROKEN Feature is installed, but not intactFeature is installed, but not intact

INSTALLSTATE_SOURCEABSENTINSTALLSTATE_SOURCEABSENT Feature is installed to run from source but the Feature is installed to run from source but the

source is missing (e.g., CD missing, net down)source is missing (e.g., CD missing, net down)

Installer DatatypesInstaller DatatypesINSTALLSTATEINSTALLSTATE

Page 11: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

How much work installer should do to How much work installer should do to provide a feature or componentprovide a feature or component MsiUseFeatureExMsiUseFeatureEx MsiProvideComponentMsiProvideComponent MsiProvideQualifiedComponentMsiProvideQualifiedComponent

INSTALLMODE_DEFAULTINSTALLMODE_DEFAULT INSTALLMODE_EXISTINGINSTALLMODE_EXISTING INSTALLMODE_NODETECTIONINSTALLMODE_NODETECTION

Save one Save one GetFileAttributesExGetFileAttributesEx call call

Installer DatatypesInstaller DatatypesINSTALLMODEINSTALLMODE

Page 12: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Used when repairing a featureUsed when repairing a feature Can use in place of INSTALLMODE flagsCan use in place of INSTALLMODE flags MsiReinstallFeatureMsiReinstallFeature MsiReinstallProductMsiReinstallProduct

REINSTALLMODE_FILEMISSINGREINSTALLMODE_FILEMISSING REINSTALLMODE_FILEEXACTREINSTALLMODE_FILEEXACT REINSTALLMODE_FILEVERIFYREINSTALLMODE_FILEVERIFY REINSTALLMODE_MACHINEDATAREINSTALLMODE_MACHINEDATA REINSTALLMODE_USERDATAREINSTALLMODE_USERDATA

Installer DatatypesInstaller DatatypesREINSTALLMODEREINSTALLMODE

Page 13: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Using FeaturesUsing Features

MsiUseFeatureMsiUseFeature when a feature is used when a feature is used Increments feature’s usage count (obtain Increments feature’s usage count (obtain

with with MsiGetFeatureUsageMsiGetFeatureUsage))

If feature not installed, install it!If feature not installed, install it! Use Use MsiConfigureFeatureMsiConfigureFeature to install to install

MsiUseFeatureExMsiUseFeatureEx combines these. combines these. If needed, get path to a component key If needed, get path to a component key

file using file using MsiGetComponentPathMsiGetComponentPath For use with LoadLibrary, CreateFile, etc.For use with LoadLibrary, CreateFile, etc.

Page 14: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

ResiliencyResiliencyWhat if LoadLibrary fails?What if LoadLibrary fails?

Features can be brokenFeatures can be broken User deletes file (LoadLibrary fails)User deletes file (LoadLibrary fails) User removes necessary registry info User removes necessary registry info

(CoCreateInstance fails)(CoCreateInstance fails)

Just offer to reinstall the feature!Just offer to reinstall the feature!

UINT MsiReinstallFeature( LPCTSTR szProduct, // product code LPCTSTR szFeature, // feature ID LPCTSTR dwReinstallMode);

Page 15: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Performance TipPerformance Tip

Installer will verify feature install statesInstaller will verify feature install states Registry lookups + one GetFileAttributes Registry lookups + one GetFileAttributes

call per feature component call per feature component

For very commonly used features (e.g., For very commonly used features (e.g., application boot), you can first just look application boot), you can first just look in the “usual place” (e.g., app directory)in the “usual place” (e.g., app directory) If LoadLibrary fails, fall back on installer If LoadLibrary fails, fall back on installer

API to find and/or reinstall featureAPI to find and/or reinstall feature Lose feature usage metrics, some safetyLose feature usage metrics, some safety

Page 16: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Published ComponentsPublished Components

Also called “Qualified Components”Also called “Qualified Components” MsiProvideQualifiedComponentMsiProvideQualifiedComponent MsiEnumComponentQualifiersMsiEnumComponentQualifiers

Very flexible scheme for managing lists Very flexible scheme for managing lists of componentsof components Examples: text converters, wizards, Examples: text converters, wizards,

templates, any per-language componenttemplates, any per-language component

Flexible way of sharing features across Flexible way of sharing features across products without hard coding products without hard coding component IDscomponent IDs

Page 17: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

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 ComponentsPublished Components

Category GUID not a component ID!Category GUID not a component ID! Think of as “array name”Think of as “array name”

Array index is szQualifierArray index is szQualifier File Type, LCID, etc.File Type, LCID, etc.

Page 18: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Published ComponentsPublished Components{5CB2D5F5-19DD-11d1-9A9D-006097C4E489}{5CB2D5F5-19DD-11d1-9A9D-006097C4E489}

““1033”, “English”1033”, “English”

““1036”, “French”1036”, “French”

““1031”, “German”1031”, “German”

{5CB2D5F5-19DD-11d1-9A9D-006097C4E500}{5CB2D5F5-19DD-11d1-9A9D-006097C4E500}

{5CB2D5F5-19DD-11d1-9A9D-006097C4E501}{5CB2D5F5-19DD-11d1-9A9D-006097C4E501}

{5CB2D5F5-19DD-11d1-9A9D-006097C4E502}{5CB2D5F5-19DD-11d1-9A9D-006097C4E502}

APPDEU.DLLAPPDEU.DLL

APPFRA.DLLAPPFRA.DLL

APPENU.DLLAPPENU.DLL

Page 19: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Published ComponentsPublished Components

UINT MsiEnumComponentQualifiers(UINT MsiEnumComponentQualifiers( LPCTSTR szCategory, // category GUIDLPCTSTR szCategory, // category GUID DWORD iIndex, // 0-based indexDWORD iIndex, // 0-based index LPTSTR szQualifier, // qualifier stringLPTSTR szQualifier, // qualifier string DWORD *pcchQualifier // in/outDWORD *pcchQualifier // in/out LPTSTR szAppData, // AppData stringLPTSTR szAppData, // AppData string DWORD *pcchAppData); // in/outDWORD *pcchAppData); // in/out

Use to populate listboxUse to populate listbox Office 2000: list of languages supportedOffice 2000: list of languages supported

AppData is intended for UIAppData is intended for UI Office 2000: user-readable language nameOffice 2000: user-readable language name

Page 20: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Shell SupportShell Support

““Installer Token”: New form of Shell Installer Token”: New form of Shell shortcut on Internet Explorer 4.01 SP 1 shortcut on Internet Explorer 4.01 SP 1 Shell, Windows 98 and Windows NTShell, Windows 98 and Windows NT®® 5.0 5.0 Encapsulates Product/Feature/ComponentEncapsulates Product/Feature/Component

Can live in Start menu or on DesktopCan live in Start menu or on Desktop Shell will detect that shortcut is an Shell will detect that shortcut is an

Installer Descriptor and invoke installer Installer Descriptor and invoke installer to provide the component pathto provide the component path

Free install on demand for appsFree install on demand for apps Note: only installs product’s main featureNote: only installs product’s main feature

Page 21: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

COM SupportCOM Support

““Installer Descriptor” can be used in Installer Descriptor” can be used in COM registry on Windows NT 5.0COM registry on Windows NT 5.0 Same format as Shell shortcutSame format as Shell shortcut

OLE will invoke installer to provide the OLE will invoke installer to provide the component pathcomponent path

Free install on demand for Free install on demand for COM componentsCOM components Note: only installs target featureNote: only installs target feature

Page 22: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

DemoDemo

MsiSpy sampleMsiSpy sample

Page 23: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Next StepsNext Steps

Add resiliency to your applicationAdd resiliency to your application Use Published Components to share Use Published Components to share

features across applicationsfeatures across applications Use Windows installer toUse Windows installer to

Make “run from network server” freeMake “run from network server” free Make automated deployment easyMake automated deployment easy Allow users/administrators to tailor Allow users/administrators to tailor

application install size without losing application install size without losing any functionalityany functionality

Use the installer for your application!Use the installer for your application!

Page 24: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Call To ActionCall To Action

Empower your applications for management!Empower your applications for management! Separate user and machine dataSeparate user and machine data

See MGMT 001See MGMT 001 Policy Enable Your ApplicationPolicy Enable Your Application

See MGMT 001, MGMT 006See MGMT 001, MGMT 006 Create a Windows installer packageCreate a Windows installer package

See MGMT 003, MGMT 004See MGMT 003, MGMT 004 Leverage the Windows installer APILeverage the Windows installer API

See MGMT 005See MGMT 005 Leverage Active Directory for Application DataLeverage Active Directory for Application Data

See DS 05, DS 06See DS 05, DS 06

Page 25: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Windows NT 5.0 LogoWindows NT 5.0 Logo

Leverage your investment in Leverage your investment in Windows installerWindows installer Install/uninstall is top concern among customersInstall/uninstall is top concern among customers 1 of 4 key areas of the 1 of 4 key areas of the newnew Windows NT 5.0 logo Windows NT 5.0 logo

Follow up infoFollow up info Draft requirements: Draft requirements:

On the conference DVDOn the conference DVD www.microsoft.com/windows/winlogo/developerwww.microsoft.com/windows/winlogo/developer

Feedback: [email protected] by 11/15Feedback: [email protected] by 11/15

Page 26: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Questions And AnswersQuestions And Answers

Page 27: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation
Page 28: Creating Dynamic And Robust Applications With The Windows ® Installer Mike Kelly Lead Software Design Engineer Microsoft Office TCO Team Microsoft Corporation

Product CodesProduct Codes

Product Product Code

Foo 1.0 A

Foo Pro 1.0 B

Foo Pro 1.1 B

Foo Pro 2.0 C