How to update a value in an msi registry table as REG_DWORD

506 views Asked by At

I need to change a value in an MSI's Registry table. The Msi is built with WIX. I need to do this in C++.

Here is what the value is to begin (ORCA): Registry.Name: Session Registry.Value: #250

I understand that the # in the Value indicates that the value is formatted and is an integer (REG_DWORD)

I have attempted this using a simple MsiViewExecute():

 MSIHANDLE MsiHandle;
 MSIHANDLE ViewHandle=(MSIHANDLE)NULL;

 MsiOpenDatabase(MsiFullPath,MSIDBOPEN_TRANSACT,&MsiHandle);

 // This Will Update The Value Of  Session To 70 But It Is A String Value (No Longer An Integer /  REG_DWORD).
 // The Value Ends Up In The registry Table A '70' (No #).
 //MsiDatabaseOpenView(MsiHandle,L"UPDATE Registry SET Registry.Value=70 WHERE (Registry.Name='Session'),&ViewHandle);

 // https://msdn.microsoft.com/en-us/library/windows/desktop/aa371168(v=vs.85).aspx 
 // Says: # The value is interpreted and stored as an integer (REG_DWORD).
 // Msi Does Not Like The #. This Returns ERROR_BAD_QUERY_SYNTAX
 MsiDatabaseOpenView(MsiHandle,L"UPDATE Registry SET Registry.Value=#70 WHERE (Registry.Name='Session'),&ViewHandle);

 MsiViewExecute(ViewHandle,(MSIHANDLE)NULL)

What am I doing wrong?

1

There are 1 answers

0
PhilDW On BEST ANSWER

The error is caused by the #70 - it needs single quoting. The field in the table is formatted, so it's text.