Summary
This article provides sample code in C++ that adds or removes values in a combo box dynamically at run time.Synopsis
You cannot remove values from a combo box at run time because the MSI Database is persistent and does not allow modification. You can add entries if they do not already exist. You can write your own DLL and then create a custom action that calls a function within this DLL to add entries to a combo box. This article provides sample code in C++ that adds or removes values in a combo box dynamically at run time.
Discussion
The following is the InstallScript code:
UINT __stdcall AppendComboBox(MSIHANDLE hInstall) {
MSIHANDLE hView, hDatabase;
PMSIHANDLE hRec;
int HowManyRecs = 17, StartRecIndex = 4;
char valuebuffer[20];
char *valbufptr = valuebuffer;
hDatabase = MsiGetActiveDatabase(hInstall);
MsiDatabaseOpenView(hDatabase, "SELECT * FROM ComboBox", &hView);
// Now append 17 records.
for (int i=0; i < HowManyRecs; i++) {
hRec = MsiCreateRecord(4);
MsiRecordSetString(hRec, 1, "COMBO"); // Column1: Property tied to the entry
MsiRecordSetInteger(hRec, 2, StartRecIndex+i);
// Column2: Display order of item
MsiRecordSetString(hRec, 3, _itoa(StartRecIndex+i, valbufptr, 10));
// Column3: Value to set property to
MsiRecordSetString(hRec, 4, _itoa(StartRecIndex+i, valbufptr, 10));
// Column4: Display text for item
MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRec);
}
MsiViewClose(hView);
return ERROR_SUCCESS;
}
Additional Information
VBScript can also be used in place of the code above. This code would then be launched via a VBScript custom action. If you would like to use VBScript, you need to use the MSI Installer Object. Sample code using this object is installed with the Windows Installer SDK.
Related Articles
Populating A List Box Dynamically At Run Time 5Number of Views Drop-Down Functionality of a Combo Box Control May Not Work 4Number of Views How to Configure IIS settings Dynamically at Run Time 4Number of Views Accessing the MSI Database at Run Time 18Number of Views How to Dynamically Populate a List Box at Runtime. 4Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Case id: 00001065
Activity: Status change: 2 hours ago