msi: Use MSI_QueryGetRecord in ACTION_AppSearchReg.

This commit is contained in:
Mike McCormack 2006-11-27 18:16:34 +09:00 committed by Alexandre Julliard
parent fa6bc9e50b
commit 54ab47ef59
1 changed files with 91 additions and 118 deletions

View File

@ -235,42 +235,31 @@ static void ACTION_ConvertRegValue(DWORD regType, const BYTE *value, DWORD sz,
static UINT ACTION_SearchDirectory(MSIPACKAGE *package, MSISIGNATURE *sig,
LPCWSTR path, int depth, LPWSTR *appValue);
static UINT ACTION_AppSearchReg(MSIPACKAGE *package, LPWSTR *appValue,
MSISIGNATURE *sig)
static UINT ACTION_AppSearchReg(MSIPACKAGE *package, LPWSTR *appValue, MSISIGNATURE *sig)
{
MSIQUERY *view;
UINT rc;
static const WCHAR ExecSeqQuery[] = {
static const WCHAR query[] = {
's','e','l','e','c','t',' ','*',' ',
'f','r','o','m',' ',
'R','e','g','L','o','c','a','t','o','r',' ',
'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e','_',' ','=',' ',
'\'','%','s','\'',0};
TRACE("(package %p, appValue %p, sig %p)\n", package, appValue, sig);
*appValue = NULL;
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, sig->Name);
if (rc == ERROR_SUCCESS)
{
MSIRECORD *row = 0;
'w','h','e','r','e',' ',
'S','i','g','n','a','t','u','r','e','_',' ','=',' ', '\'','%','s','\'',0};
LPWSTR keyPath = NULL, valueName = NULL;
int root, type;
HKEY rootKey, key = NULL;
DWORD sz = 0, regType;
LPBYTE value = NULL;
MSIRECORD *row;
UINT rc;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
TRACE("%s\n", debugstr_w(sig->Name));
*appValue = NULL;
row = MSI_QueryGetRecord( package->db, query, sig->Name );
if (!row)
{
TRACE("MSI_ViewExecute returned %d\n", rc);
goto end;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
TRACE("MSI_ViewFetch returned %d\n", rc);
rc = ERROR_SUCCESS;
goto end;
TRACE("failed to query RegLocator for %s\n", debugstr_w(sig->Name));
return ERROR_SUCCESS;
}
root = MSI_RecordGetInteger(row,2);
@ -303,14 +292,13 @@ static UINT ACTION_AppSearchReg(MSIPACKAGE *package, LPWSTR *appValue,
if (rc)
{
TRACE("RegOpenKeyW returned %d\n", rc);
rc = ERROR_SUCCESS;
goto end;
}
rc = RegQueryValueExW(key, valueName, NULL, NULL, NULL, &sz);
if (rc)
{
TRACE("RegQueryValueExW returned %d\n", rc);
rc = ERROR_SUCCESS;
goto end;
}
/* FIXME: sanity-check sz before allocating (is there an upper-limit
@ -321,25 +309,20 @@ static UINT ACTION_AppSearchReg(MSIPACKAGE *package, LPWSTR *appValue,
if (rc)
{
TRACE("RegQueryValueExW returned %d\n", rc);
rc = ERROR_SUCCESS;
goto end;
}
/* bail out if the registry key is empty */
if (sz == 0)
{
rc = ERROR_SUCCESS;
goto end;
}
switch (type & 0x0f)
{
case msidbLocatorTypeDirectory:
rc = ACTION_SearchDirectory(package, sig, (LPCWSTR)value, 0,
appValue);
rc = ACTION_SearchDirectory(package, sig, (LPWSTR)value, 0, appValue);
break;
case msidbLocatorTypeFileName:
*appValue = strdupW((LPCWSTR)value);
*appValue = strdupW((LPWSTR)value);
break;
case msidbLocatorTypeRawValue:
ACTION_ConvertRegValue(regType, value, sz, appValue);
@ -355,19 +338,9 @@ end:
msi_free( keyPath );
msi_free( valueName );
if (row)
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
}
else
{
TRACE("MSI_OpenQuery returned %d\n", rc);
rc = ERROR_SUCCESS;
}
TRACE("returning %d\n", rc);
return rc;
return ERROR_SUCCESS;
}
static UINT ACTION_AppSearchIni(MSIPACKAGE *package, LPWSTR *appValue,