Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends,

I have a requirement for creating a .msi file run time.

For that, I need to use Windows Installer API from C++ code.

I was searching, but I could find the samples only with C#, not C++.

Is C++ not a good idea to create an .msi file?

Thanks a lot for your help.

-Ravi
Posted

you CAN - i've done it - but it's poorly documented - our msicreator has probably taken a couple of man-years to get to its current state

MSI Database sdk[^]

Some direction :)

1. understand WHAT an MSI is - a bunch of tables (accessed thru sql'ish commands) and some compressed file streams - it uses the OTHER apostrophe (`) for column names
2. the summaryStream is very important to get right
3. use orca (in the sdk) to debug/examine MSIs with (the ICE tests are invaluable)
4. DO NOT EVEN ATTEMPT to build one from a standing start - have a 'template' MSI and add things to that
5. at the very least you need to understand Component, File, Feature, Property and the Execution tables
6. understand what the ProductCode does - you probably want a new one for each MSI you build

strategy

1. Copy your template MSI (ISTR there's one in the MSI SDK)
2. Set your properties into the Property Tables (ProductName, ProductVersion, ProductCode, ProductLang etc)
3. Add your features, your components to those features, and files to those components, taking care to get the directory table right (this is all done with sql)
4. (optionally) insert your file data into the MSI streams - you CAN simply point to SxS files, I use CAB'd content, which mandates learning the the FCI C++ (cab) interface
5. Sort out the summary stream
6. lots of testing



or look at WiX[^] - build a WiX xml file and shell out to that at runtime

if i had to do it again, i'd use WiX - it didn't exist when we started
 
Share this answer
 
v2
Thank you very much Barneyman for your answer. It is very helpful.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900