📄 classes.c
字号:
lstrcpyW( argument, file->TargetPath );
if (cls->Argument)
{
lstrcatW( argument, szSpace );
lstrcatW( argument, cls->Argument );
}
msi_reg_set_val_str( hkey3, NULL, argument );
msi_free(argument);
RegCloseKey(hkey3);
if (cls->ProgID || cls->ProgIDText)
{
LPCWSTR progid;
if (cls->ProgID)
progid = cls->ProgID->ProgID;
else
progid = cls->ProgIDText;
msi_reg_set_subkey_val( hkey2, szProgID, NULL, progid );
if (cls->ProgID && cls->ProgID->VersionInd)
{
msi_reg_set_subkey_val( hkey2, szVIProgID, NULL,
cls->ProgID->VersionInd->ProgID );
}
}
if (cls->AppID)
{
MSIAPPID *appid = cls->AppID;
msi_reg_set_val_str( hkey2, szAppID, appid->AppID );
register_appid( appid, cls->Description );
}
if (cls->IconPath)
{
static const WCHAR szDefaultIcon[] =
{'D','e','f','a','u','l','t','I','c','o','n',0};
msi_reg_set_subkey_val( hkey2, szDefaultIcon, NULL, cls->IconPath );
}
if (cls->DefInprocHandler)
{
static const WCHAR szInproc[] =
{'I','n','p','r','o','c','H','a','n','d','l','e','r',0};
msi_reg_set_subkey_val( hkey2, szInproc, NULL, cls->DefInprocHandler );
}
if (cls->DefInprocHandler32)
{
static const WCHAR szInproc32[] =
{'I','n','p','r','o','c','H','a','n','d','l','e','r','3','2',0};
msi_reg_set_subkey_val( hkey2, szInproc32, NULL, cls->DefInprocHandler32 );
}
RegCloseKey(hkey2);
/* if there is a FileTypeMask, register the FileType */
if (cls->FileTypeMask)
{
LPWSTR ptr, ptr2;
LPWSTR keyname;
INT index = 0;
ptr = cls->FileTypeMask;
while (ptr && *ptr)
{
ptr2 = strchrW(ptr,';');
if (ptr2)
*ptr2 = 0;
keyname = msi_alloc( (strlenW(szFileType_fmt) + strlenW(cls->clsid) + 4) * sizeof(WCHAR));
sprintfW( keyname, szFileType_fmt, cls->clsid, index );
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, ptr );
msi_free(keyname);
if (ptr2)
ptr = ptr2+1;
else
ptr = NULL;
index ++;
}
}
uirow = MSI_CreateRecord(1);
MSI_RecordSetStringW( uirow, 1, cls->clsid );
ui_actiondata(package,szRegisterClassInfo,uirow);
msiobj_release(&uirow->hdr);
}
RegCloseKey(hkey);
return rc;
}
static LPCWSTR get_clsid_of_progid( MSIPROGID *progid )
{
while (progid)
{
if (progid->Class)
return progid->Class->clsid;
progid = progid->Parent;
}
return NULL;
}
static UINT register_progid( MSIPROGID* progid )
{
static const WCHAR szCLSID[] = { 'C','L','S','I','D',0 };
static const WCHAR szDefaultIcon[] =
{'D','e','f','a','u','l','t','I','c','o','n',0};
static const WCHAR szCurVer[] =
{'C','u','r','V','e','r',0};
HKEY hkey = 0;
UINT rc;
rc = RegCreateKeyW( HKEY_CLASSES_ROOT, progid->ProgID, &hkey );
if (rc == ERROR_SUCCESS)
{
LPCWSTR clsid = get_clsid_of_progid( progid );
if (clsid)
msi_reg_set_subkey_val( hkey, szCLSID, NULL, clsid );
else
ERR("%s has no class\n", debugstr_w( progid->ProgID ) );
if (progid->Description)
msi_reg_set_val_str( hkey, NULL, progid->Description );
if (progid->IconPath)
msi_reg_set_subkey_val( hkey, szDefaultIcon, NULL, progid->IconPath );
/* write out the current version */
if (progid->CurVer)
msi_reg_set_subkey_val( hkey, szCurVer, NULL, progid->CurVer->ProgID );
RegCloseKey(hkey);
}
else
ERR("failed to create key %s\n", debugstr_w( progid->ProgID ) );
return rc;
}
UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package)
{
MSIPROGID *progid;
MSIRECORD *uirow;
load_classes_and_such(package);
LIST_FOR_EACH_ENTRY( progid, &package->progids, MSIPROGID, entry )
{
/* check if this progid is to be installed */
if (progid->Class && progid->Class->Installed)
progid->InstallMe = TRUE;
if (!progid->InstallMe)
{
TRACE("progid %s not scheduled to be installed\n",
debugstr_w(progid->ProgID));
continue;
}
TRACE("Registering progid %s\n", debugstr_w(progid->ProgID));
register_progid( progid );
uirow = MSI_CreateRecord( 1 );
MSI_RecordSetStringW( uirow, 1, progid->ProgID );
ui_actiondata( package, szRegisterProgIdInfo, uirow );
msiobj_release( &uirow->hdr );
}
return ERROR_SUCCESS;
}
static UINT register_verb(MSIPACKAGE *package, LPCWSTR progid,
MSICOMPONENT* component, MSIEXTENSION* extension,
MSIVERB* verb, INT* Sequence )
{
LPWSTR keyname;
HKEY key;
static const WCHAR szShell[] = {'s','h','e','l','l',0};
static const WCHAR szCommand[] = {'c','o','m','m','a','n','d',0};
static const WCHAR fmt[] = {'\"','%','s','\"',' ','%','s',0};
static const WCHAR fmt2[] = {'\"','%','s','\"',0};
LPWSTR command;
DWORD size;
LPWSTR advertise;
keyname = build_directory_name(4, progid, szShell, verb->Verb, szCommand);
TRACE("Making Key %s\n",debugstr_w(keyname));
RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key);
size = strlenW(component->FullKeypath);
if (verb->Argument)
size += strlenW(verb->Argument);
size += 4;
command = msi_alloc(size * sizeof (WCHAR));
if (verb->Argument)
sprintfW(command, fmt, component->FullKeypath, verb->Argument);
else
sprintfW(command, fmt2, component->FullKeypath);
msi_reg_set_val_str( key, NULL, command );
msi_free(command);
advertise = create_component_advertise_string(package, component,
extension->Feature->Feature);
size = strlenW(advertise);
if (verb->Argument)
size += strlenW(verb->Argument);
size += 4;
command = msi_alloc_zero(size * sizeof (WCHAR));
strcpyW(command,advertise);
if (verb->Argument)
{
static const WCHAR szSpace[] = {' ',0};
strcatW(command,szSpace);
strcatW(command,verb->Argument);
}
msi_reg_set_val_multi_str( key, szCommand, command );
RegCloseKey(key);
msi_free(keyname);
msi_free(advertise);
msi_free(command);
if (verb->Command)
{
keyname = build_directory_name(3, progid, szShell, verb->Verb);
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, verb->Command );
msi_free(keyname);
}
if (verb->Sequence != MSI_NULL_INTEGER)
{
if (*Sequence == MSI_NULL_INTEGER || verb->Sequence < *Sequence)
{
*Sequence = verb->Sequence;
keyname = build_directory_name(2, progid, szShell);
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, keyname, NULL, verb->Verb );
msi_free(keyname);
}
}
return ERROR_SUCCESS;
}
UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package)
{
static const WCHAR szContentType[] =
{'C','o','n','t','e','n','t',' ','T','y','p','e',0 };
HKEY hkey;
MSIEXTENSION *ext;
MSIRECORD *uirow;
BOOL install_on_demand = TRUE;
load_classes_and_such(package);
/* We need to set install_on_demand based on if the shell handles advertised
* shortcuts and the like. Because Mike McCormack is working on this i am
* going to default to TRUE
*/
LIST_FOR_EACH_ENTRY( ext, &package->extensions, MSIEXTENSION, entry )
{
LPWSTR extension;
MSIFEATURE *feature;
if (!ext->Component)
continue;
feature = ext->Feature;
/*
* yes. MSDN says that these are based on _Feature_ not on
* Component. So verify the feature is to be installed
*/
if ((!ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_LOCAL )) &&
!(install_on_demand &&
ACTION_VerifyFeatureForAction( feature, INSTALLSTATE_ADVERTISED )))
{
TRACE("Skipping extension %s reg due to disabled feature %s\n",
debugstr_w(ext->Extension), debugstr_w(feature->Feature));
continue;
}
TRACE("Registering extension %s (%p)\n", debugstr_w(ext->Extension), ext);
ext->Installed = TRUE;
/* this is only registered if the extension has at least 1 verb
* according to MSDN
*/
if (ext->ProgID && !list_empty( &ext->verbs ) )
mark_progid_for_install( package, ext->ProgID );
mark_mime_for_install(ext->Mime);
extension = msi_alloc( (lstrlenW( ext->Extension ) + 2)*sizeof(WCHAR) );
extension[0] = '.';
lstrcpyW(extension+1,ext->Extension);
RegCreateKeyW(HKEY_CLASSES_ROOT,extension,&hkey);
msi_free( extension );
if (ext->Mime)
msi_reg_set_val_str( hkey, szContentType, ext->Mime->ContentType );
if (ext->ProgID || ext->ProgIDText)
{
static const WCHAR szSN[] =
{'\\','S','h','e','l','l','N','e','w',0};
HKEY hkey2;
LPWSTR newkey;
LPCWSTR progid;
MSIVERB *verb;
INT Sequence = MSI_NULL_INTEGER;
if (ext->ProgID)
progid = ext->ProgID->ProgID;
else
progid = ext->ProgIDText;
msi_reg_set_val_str( hkey, NULL, progid );
newkey = msi_alloc( (strlenW(progid)+strlenW(szSN)+1) * sizeof(WCHAR));
strcpyW(newkey,progid);
strcatW(newkey,szSN);
RegCreateKeyW(hkey,newkey,&hkey2);
RegCloseKey(hkey2);
msi_free(newkey);
/* do all the verbs */
LIST_FOR_EACH_ENTRY( verb, &ext->verbs, MSIVERB, entry )
{
register_verb( package, progid, ext->Component,
ext, verb, &Sequence);
}
}
RegCloseKey(hkey);
uirow = MSI_CreateRecord(1);
MSI_RecordSetStringW( uirow, 1, ext->Extension );
ui_actiondata(package,szRegisterExtensionInfo,uirow);
msiobj_release(&uirow->hdr);
}
return ERROR_SUCCESS;
}
UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package)
{
static const WCHAR szExten[] =
{'E','x','t','e','n','s','i','o','n',0 };
MSIRECORD *uirow;
MSIMIME *mt;
load_classes_and_such(package);
LIST_FOR_EACH_ENTRY( mt, &package->mimes, MSIMIME, entry )
{
LPWSTR extension;
LPCWSTR exten;
LPCWSTR mime;
static const WCHAR fmt[] =
{'M','I','M','E','\\','D','a','t','a','b','a','s','e','\\',
'C','o','n','t','e','n','t',' ','T','y','p','e','\\', '%','s',0};
LPWSTR key;
/*
* check if the MIME is to be installed. Either as requesed by an
* extension or Class
*/
mt->InstallMe = (mt->InstallMe ||
(mt->Class && mt->Class->Installed) ||
(mt->Extension && mt->Extension->Installed));
if (!mt->InstallMe)
{
TRACE("MIME %s not scheduled to be installed\n",
debugstr_w(mt->ContentType));
continue;
}
mime = mt->ContentType;
exten = mt->Extension->Extension;
extension = msi_alloc( (lstrlenW( exten ) + 2)*sizeof(WCHAR) );
extension[0] = '.';
lstrcpyW(extension+1,exten);
key = msi_alloc( (strlenW(mime)+strlenW(fmt)+1) * sizeof(WCHAR) );
sprintfW(key,fmt,mime);
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, szExten, extension );
msi_free(extension);
msi_free(key);
if (mt->clsid)
FIXME("Handle non null for field 3\n");
uirow = MSI_CreateRecord(2);
MSI_RecordSetStringW(uirow,1,mt->ContentType);
MSI_RecordSetStringW(uirow,2,exten);
ui_actiondata(package,szRegisterMIMEInfo,uirow);
msiobj_release(&uirow->hdr);
}
return ERROR_SUCCESS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -