////////////////////////////////////////////////////////////////
//
//
Function: PopulateDefaultEngineslist
//
// Purpose: Populates engines list combobox for selection to be default.
//
//
////////////////////////////////////////////////////////////////
prototype PopulateDefaultEngineslist(HWND,STRING,STRING,STRING);
function PopulateDefaultEngineslist(hMSI,SelectCM,SelectCPE,SelectUE)
HWND hDB, hView,hPropView,hPropRecord, hRecord;
LIST listID;
NUMBER nResult, nCounter;
STRING svListString, szTmp,szFirstItem;
begin
hDB = MsiGetActiveDatabase(hMSI);
MsiDatabaseOpenView(hDB,"SELECT * FROM ComboBox", hView);
// Create an empty string list.
listID = ListCreate (STRINGLIST);
// If an error occurred, report it; then terminate.
if (listID = LIST_NULL) then
MessageBox ("Unable to create list.", SEVERE);
abort;
endif;
if (ListAddString (listID, "Select Engine", AFTER) < 0) then
MessageBox ("ListAddString failed.", INFORMATION);
endif;
// Add a string to the list. This string becomes the current element.
if ( SelectCM = "true" ) then
if (ListAddString (listID, "CM", AFTER) < 0) then
MessageBox ("ListAddString failed.", INFORMATION);
endif;
if(szFirstItem == "") then
szFirstItem = "CM";
endif;
endif;
if ( SelectCPE = "true" ) then
if (ListAddString (listID, "CPE", AFTER) < 0) then
MessageBox ("ListAddString failed.", INFORMATION);
endif;
if(szFirstItem == "") then
szFirstItem = "CPE";
endif;
endif;
// Add a third string; insert it before the current element.
if ( SelectUE = "true" ) then
if (ListAddString (listID, "UE", AFTER) < 0) then
MessageBox ("ListAddString failed.", INFORMATION);
endif;
if(szFirstItem == "") then
szFirstItem = "UE";
endif;
endif;
// Retrieve and display the current element.
//ListCurrentString (listID, svString);
nResult = ListGetFirstString (listID, svListString);
while (nResult != END_OF_LIST)
hRecord = MsiCreateRecord(4);
NumToStr(szTmp,nCounter);
MsiRecordSetString(hRecord, 1, "DEFAULT_ENGINE");// Column 1 PROPERTY
MsiRecordSetInteger(hRecord, 2, nCounter); // Column2: Display order of the item
MsiRecordSetString(hRecord, 3, svListString); // Column3: Value to set property to
MsiRecordSetString(hRecord, 4, svListString); // Column4: Display text for item
MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRecord);
nCounter=nCounter+1;
nResult = ListGetNextString (listID, svListString);
endwhile;
MsiCloseHandle(hRecord);
MsiViewClose(hView);
MsiCloseHandle(hView);
MsiCloseHandle(hDB);
// Remove the list from memory.
ListDestroy (listID);
end;
-----------------------