cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DLee65
Level 13

MsiViewGetColumnInfo returns 131078

I am trying to use MsiViewGetColumnInfo to determine MSICOLINFO_TYPES. However, I am having problems with implementing this function. Below is the code I have in place and from what I am reading the code seems to be correct syntax.


hDB = MsiGetActiveDatabase(p_hMSI);
sQuery = "SELECT * FROM `Shortcut` WHERE `Shortcut`.`Shortcut`=" + "'" + sNEW_KeyName + "'";
n = MsiDatabaseOpenView(hDB, sQuery, hView);
n = MsiViewExecute(hView, hRec);
n = MsiViewGetColumnInfo(hView, MSICOLINFO_TYPES, hRec); //returns n=131078. Should return one of four values



The expected return values are:
ERROR_INVALID_HANDLE 6
An invalid or inactive handle was supplied.
ERROR_INVALID_HANDLE_STATE 1609
The view is not in an active state.
ERROR_INVALID_PARAMETER 87
An invalid MSICOLINFO column information enumeration value was passed to the function.
ERROR_SUCCESS 0

The return value above does not correspond to any of these values. My calls to MsiViewFetch(hView, hRec) work just fine.
Labels (1)
0 Kudos
(2) Replies
DLee65
Level 13

I have been around and around on this. I cannot explain even what the error number represents. I tried searching for its Hex value in all header files and it is not defined. 00020006 is the Hex value of 131078. Searching online reveals nothing about this code. At best all I can guess is that it represents an invalid memory address, however, that is contrary to what the function is supposed to return.

Has anyone else had success using MsiViewGetColumnInfo that can check to see if I am missing something in my implementation?

Thanks.
0 Kudos
DLee65
Level 13

I found a setup.rul file that contains the implementation of MsiViewGetColumnInfo. In the IS2008 directory Samples\ScriptSamples\ScriptSamples\Setup.rul. This has the following implementation.

function NUMBER GetNumCols(hView)
NUMBER nResult, hRec, nRecVal, nColCtr;
begin
// create a large record
hRec = MsiCreateRecord(MAX_RECORD);

// retrieve the column information for the view into our large record
nResult = MsiViewGetColumnInfo(hView, MSICOLINFO_NAMES, hRec);

nRecVal = 1;
nColCtr = 0;

// iterate until an empty header is found.
while (nRecVal != 0)
nColCtr = nColCtr + 1;
nRecVal = MsiRecordDataSize(hRec, nColCtr);
endwhile;

MsiCloseHandle(hRec);

// the above while loop terminates on the first empty column, so we
// subtract one to get the record size.
return (nColCtr - 1);
end;


I note here that the handle to the view is passed in as a parameter. The only difference between my implementation and what I see here is the Data Type for hRec. I use the HWND data type whereas this file uses the NUMBER Data Type. It is my understanding that these are fundamentally the same data type however.

Also, this morning I am fairly certain that the value 131078 is NOT a bad memory address as I doubt the same value would return on each test if it were a bad memory address. So, is there anyone out there with some knowledge of this function? Thanks.

EDIT: Another thing I tried was to create a very large record (1024) just in case that the record is larger than I expected. I still get back the useless 131078. I guess I will have to give up on this approach and statically establish which fields are integer types and which are string types.
0 Kudos