Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

MsiFormatRecord return strange content


2 replies to this topic

Claas Hilbrecht

Claas Hilbrecht
  • Members
  • 4 posts

Posted 21 November 2001 - 11:34

In a CA I use MsiFormatRecord to format an entry that I retrieve from the Registry table. The returned buffer looks somewhat funny (see below).

Here is the code sequence (not complete, error checking and buffer allocation is stripped):

rc = MsiDatabaseOpenView(hDB, _T("SELECT * FROM Registry"), &hView);
rc = MsiViewExecute(hView, 0);
rc = MsiViewFetch(hView, &hRecord);
rc = MsiRecordGetString(hRecord, 3, pBuff, &BuffLen);
PMSIHANDLE hTmpRec;
hTmpRec = MsiCreateRecord(1);
rc = MsiRecordSetString(hTmpRec, 1, pBuff);
DWORD BuffLen = MSIBUFFLEN;
rc = MsiFormatRecord(MsiHandle, hTmpRec, pBuff, &BuffLen);

All return codes are ok. My problem is that MsiFormatRecord return the following in pBuff after return (note the spaces and the 1:):

"1: SOFTWARE\Linum\DCF77\2.10\rxserial "

The original entry in the registry table is:
Root: 2
Key: "SOFTWARE\Linum\DCF77\2.10\rxserial"

After reading the MSI SDK documentation I would assume the I get "SOFTWARE\Linum\DCF77\2.10\rxserial" in pBuff. The string return looks nearly like the result from MsiGetComponentPath().

My question are:

1) Why is the returned string formatted this way?
2) Is this behaviour documented somewhere? I can't find information about this.
3) What can I elso do to expand all properties in a string?

PS: I want to use the code to create temporary entries in the registry table during an upgrade. Before removing the old product I walk through the registry and add all keys that are not included in the registry table as temporary entries. To compare the values from the registry scan with the values in the registry database I need to expand possible properties in the key and name coloum with MsiFormatRecord.


Ian Blake

Ian Blake
  • Members
  • 483 posts

Posted 21 November 2001 - 15:20

Try
rc = MsiRecordSetString((hTmpRec, 0, pBuff);

I am surprised your code worked at all.


Claas Hilbrecht

Claas Hilbrecht
  • Members
  • 4 posts

Posted 21 November 2001 - 15:39

Thanks very much. That's it. I wonder why I didn't get an error. I used the "1" offset because the MsiCreateRecord() documentation says:

Field 0 of the record object created by the MsiCreateRecord function is used for format strings and operation codes and is not included in the count specified by cParams.

I thought the 0 field is not usable for other purposes.