Commit 7f26cffd authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Simplify register_progid() and remove a fixed length buffer.

parent cad96777
...@@ -179,7 +179,7 @@ static MSIPROGID *load_progid( MSIPACKAGE* package, MSIRECORD *row ) ...@@ -179,7 +179,7 @@ static MSIPROGID *load_progid( MSIPACKAGE* package, MSIRECORD *row )
while (parent->Parent && parent->Parent != parent) while (parent->Parent && parent->Parent != parent)
parent = parent->Parent; parent = parent->Parent;
FIXME("need to determing if we are really the CurVer\n"); /* FIXME: need to determing if we are really the CurVer */
progid->CurVer = parent; progid->CurVer = parent;
parent->VersionInd = progid; parent->VersionInd = progid;
...@@ -1041,67 +1041,36 @@ UINT ACTION_RegisterClassInfo(MSIPACKAGE *package) ...@@ -1041,67 +1041,36 @@ UINT ACTION_RegisterClassInfo(MSIPACKAGE *package)
return rc; return rc;
} }
static UINT register_progid_base( MSIPROGID* progid, LPWSTR clsid ) static LPCWSTR get_clsid_of_progid( MSIPROGID *progid )
{ {
static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; while (progid)
static const WCHAR szDefaultIcon[] =
{'D','e','f','a','u','l','t','I','c','o','n',0};
HKEY hkey;
RegCreateKeyW(HKEY_CLASSES_ROOT,progid->ProgID,&hkey);
if (progid->Description)
msi_reg_set_val_str( hkey, NULL, progid->Description );
if (progid->Class)
{ {
msi_reg_set_subkey_val( hkey, szCLSID, NULL, progid->Class->clsid ); if (progid->Class)
if (clsid) return progid->Class->clsid;
strcpyW( clsid, progid->Class->clsid ); progid = progid->Parent;
}
else
{
FIXME("progid (%s) with null classid\n", debugstr_w(progid->ProgID));
} }
return NULL;
if (progid->IconPath)
msi_reg_set_subkey_val( hkey, szDefaultIcon, NULL, progid->IconPath );
return ERROR_SUCCESS;
} }
static UINT register_progid(MSIPACKAGE *package, MSIPROGID* progid, static UINT register_progid( MSIPROGID* progid )
LPWSTR clsid)
{ {
UINT rc = ERROR_SUCCESS;
if (progid->Parent == NULL)
rc = register_progid_base( progid, clsid );
else
{
DWORD disp;
HKEY hkey;
static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 }; static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 };
static const WCHAR szDefaultIcon[] = static const WCHAR szDefaultIcon[] =
{'D','e','f','a','u','l','t','I','c','o','n',0}; {'D','e','f','a','u','l','t','I','c','o','n',0};
static const WCHAR szCurVer[] = static const WCHAR szCurVer[] =
{'C','u','r','V','e','r',0}; {'C','u','r','V','e','r',0};
HKEY hkey = 0;
UINT rc;
/* check if already registered */ rc = RegCreateKeyW( HKEY_CLASSES_ROOT, progid->ProgID, &hkey );
RegCreateKeyExW(HKEY_CLASSES_ROOT, progid->ProgID, 0, NULL, 0, if (rc == ERROR_SUCCESS)
KEY_ALL_ACCESS, NULL, &hkey, &disp );
if (disp == REG_OPENED_EXISTING_KEY)
{ {
TRACE("Key already registered\n"); LPCWSTR clsid = get_clsid_of_progid( progid );
RegCloseKey(hkey);
return rc;
}
TRACE("Registering Parent %s\n", debugstr_w(progid->Parent->ProgID) );
rc = register_progid( package, progid->Parent, clsid );
/* clsid is same as parent */ if (clsid)
msi_reg_set_subkey_val( hkey, szCLSID, NULL, clsid ); msi_reg_set_subkey_val( hkey, szCLSID, NULL, clsid );
else
ERR("%s has no class\n", debugstr_w( progid->ProgID ) );
if (progid->Description) if (progid->Description)
msi_reg_set_val_str( hkey, NULL, progid->Description ); msi_reg_set_val_str( hkey, NULL, progid->Description );
...@@ -1115,6 +1084,9 @@ static UINT register_progid(MSIPACKAGE *package, MSIPROGID* progid, ...@@ -1115,6 +1084,9 @@ static UINT register_progid(MSIPACKAGE *package, MSIPROGID* progid,
RegCloseKey(hkey); RegCloseKey(hkey);
} }
else
ERR("failed to create key %s\n", debugstr_w( progid->ProgID ) );
return rc; return rc;
} }
...@@ -1130,8 +1102,6 @@ UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package) ...@@ -1130,8 +1102,6 @@ UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package)
LIST_FOR_EACH_ENTRY( progid, &package->progids, MSIPROGID, entry ) LIST_FOR_EACH_ENTRY( progid, &package->progids, MSIPROGID, entry )
{ {
WCHAR clsid[0x1000];
/* check if this progid is to be installed */ /* check if this progid is to be installed */
if (progid->Class && progid->Class->Installed) if (progid->Class && progid->Class->Installed)
progid->InstallMe = TRUE; progid->InstallMe = TRUE;
...@@ -1145,9 +1115,9 @@ UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package) ...@@ -1145,9 +1115,9 @@ UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package)
TRACE("Registering progid %s\n", debugstr_w(progid->ProgID)); TRACE("Registering progid %s\n", debugstr_w(progid->ProgID));
register_progid( package, progid, clsid ); register_progid( progid );
uirow = MSI_CreateRecord(1); uirow = MSI_CreateRecord( 1 );
MSI_RecordSetStringW( uirow, 1, progid->ProgID ); MSI_RecordSetStringW( uirow, 1, progid->ProgID );
ui_actiondata( package, szRegisterProgIdInfo, uirow ); ui_actiondata( package, szRegisterProgIdInfo, uirow );
msiobj_release( &uirow->hdr ); msiobj_release( &uirow->hdr );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment