cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Blueeberry
Level 4

How to read feature table from direct editor

Hi

How can I read the feature names from the direct editor?
I use an InstallScript MSI Project.
I don't know how to use MsiGetActiveDatabase(); and the other Msi-Commands... I hope you can help me. Thanks



Regards

Blueeberry
Labels (1)
0 Kudos
(3) Replies
RobertDickau
Flexera Alumni

For InstallScript MSI, perhaps look into using FeatureListItems to list features, and FeatureGetData for other information?

For general MSI information, perhaps see this old newsletter tip (PDF): http://www.acresso.com/webdocuments/PDF/msiaccess.pdf. Also see the InstallShield topic "Windows Installer API Functions Example" for an InstallScript version of one of the examples.
0 Kudos
Blueeberry
Level 4

Hi Robert

I found a way to read it from the Feature Table...
Thank you for you answer.


hActiveDB = MsiGetActiveDatabase(ISMSI_HANDLE);
nResult = MsiDatabaseOpenView(hActiveDB, "SELECT Feature FROM Feature", phView);

if (nResult = ERROR_SUCCESS) then

nResult = MsiViewExecute(phView, 0);
if(nResult = ERROR_SUCCESS) then

Ok = TRUE;
while(Ok = TRUE)
nChars = 50;
nResult = MsiViewFetch(phView, phResultRecord);
if(nResult = ERROR_SUCCESS) then
nResult = MsiRecordGetString(phResultRecord, 1, sFeature, nChars);
FeatureGetData(MEDIA, sFeature, FEATURE_FIELD_SELECTED, nReturn, sReturn);
if(nResult = ERROR_SUCCESS) then
if(nReturn = TRUE) then
ListAddString(lSFeature, sFeature, AFTER);
endif;
else
Ok = FALSE;
endif;
else
Ok = FALSE;
endif;
endwhile;
endif;
endif;
endif;


regards

Blueeberry
0 Kudos
TechnoDex
Level 2

Thanks to the post above here is my take on the code to work around the installshield bug that the FeatureListItems() does not work

export prototype FeatureListItemsEx(HWND, LIST, STRING);

// Extension method to retrieve the list of Child Features in the MEDIA (MSI) database
// as the InstallScript's FeatureListItems() does not work
function FeatureListItemsEx(hMSI, aChildFeaturesList, aParentFeatureName)
STRING childFeatureQuery;
STRING childFeatureName;
NUMBER result;
NUMBER bufferSize;
HWND hActiveDB;
HWND phView;
HWND phResultRecord;
begin
try
childFeatureQuery = "SELECT Feature FROM Feature WHERE Feature_Parent='" + aParentFeatureName + "'";

hActiveDB = MsiGetActiveDatabase(hMSI);
//Open/Create a view against the database using the query provided
result = MsiDatabaseOpenView(hActiveDB, childFeatureQuery, phView);

//Verify that the MSI database could be opened and the View created
if (result = ERROR_SUCCESS) then

//Execute the query/view
result = MsiViewExecute(phView, 0);

if (result = ERROR_SUCCESS) then

//Process the results of the query by looping through the records returned
while (MsiViewFetch(phView, phResultRecord) = ERROR_SUCCESS)
bufferSize = 255;

//Extract the first value (i.e. Feature "Name") from the record
result = MsiRecordGetString(phResultRecord, 1, childFeatureName, bufferSize);

if (result = ERROR_SUCCESS) then
ListAddString(aChildFeaturesList, childFeatureName, AFTER);
endif;
endwhile;
endif;
endif;
catch
MessageBox("Err.Description: '" + Err.Description + "'", INFORMATION);
endcatch;
end;
0 Kudos