Populating a list box from a combo box
Posted 21 February 2002 - 19:08
Posted 21 February 2002 - 20:01
You can create a property for the ComboBox and set the selected value to this property. Then get this property in the custom action and use it ti fill the LIstBox. It may be in InstallScript (I copyied my code). You can read it and get what do you need.
STRING szKey, szName, svValue, svOption;
NUMBER nvType, nvSize, nResult, nRes;
LIST listID;
STRINGsvComputerName[126],szNameDatabaseInstance, svString;
NUMBER dSize, nValue;
STRING szTemp;
NUMBER dSizeTemp;
STRING szProp;
NUMBER hDatabase, hView, hRec;
STRING sQuery;
begin
//open msi database
hDatabase = MsiGetActiveDatabase(hMSI);
//query ListBox to add items in it
sQuery = "SELECT * FROM ListBox WHERE Property='YOURLISTBOXPROPERTY'";
MsiDatabaseOpenView(hDatabase, sQuery, hView);
hRec=MsiCreateRecord(4);
// get property [USER]
dSize = 126;
dSizeTemp = 126;
MsiGetProperty(hMSI, "YOURCOMBOBOXPROPERTY", svComputerName, dSize);
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szKey = "SOFTWARE\\Microsoft\\Microsoft SQL Server";
szName = "InstalledInstances";
if(RegDBGetKeyValueEx(szKey,szName,nvType,svValue,nvSize)= 0) then
listID = ListCreate(STRINGLIST);
StrGetTokens(listID,svValue,"");
nValue = 0;
// Change list before show it.
nResult = ListGetFirstString(listID, svOption);
while (nResult != END_OF_LIST)
// Create new string for Option list
if (svOption = "MSSQLSERVER") then
svOption = svComputerName; // ComputerName
else
svOption = svComputerName + "\\" + svOption;
endif;
nRes = ListSetCurrentString(listID , svOption);
//order in list
nValue = nValue + 1;
// add new item to ListBox
MsiRecordSetString(hRec, 1, "'YOURLISTBOXPROPERTY'");
MsiRecordSetInteger(hRec, 2, nValue);
MsiRecordSetString(hRec, 3, svOption);
MsiRecordSetString(hRec, 4, svOption);
MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRec);
// get next item
nResult = ListGetNextString(listID, svOption);
endwhile;
endif; // key exists
//close view
MsiViewClose(hView);
end; // SelectInstance
I hope it will be helpfull.