Windows 资源管理器和自定义快捷方式文件类型
Windows Explorer & custom shortcut file types
Windows 在文件注册中有一个名为 "IsShortcut" 的标志。设置此标志后,文件会自动获得快捷方式图标覆盖,并在其他方面被视为快捷方式(例如,当您右键单击并 select "Create Shortcut" 时,它只是复制文件而不是生成 .lnk 文件)。 Microsoft 将此功能用于 ClickOnce 应用程序引用(扩展名 .appref-ms
)。
我们将此功能用于我们自己软件的自定义快捷方式文件类型,我们发现自 Windows 10(或可能 Windows 8)以来,我们的自定义快捷方式不出现在开始菜单中。开始菜单当然列出了.lnk
个文件,它也包括了.appref-ms
个文件,但是我们自己的文件格式,其注册方式与.appref-ms
个文件,已从“开始”菜单中排除。快捷方式文件实际存在于“开始”菜单文件夹结构 (%APPDATA%\Microsoft\Windows\Start Menu\Programs
) 中,但会被 Windows 资源管理器忽略。同一目录中的其他快捷方式类型(.lnk
和 .appref-ms
)会显示。
我正在寻找的是 Windows Explorer 如何确定它将包含在“开始”菜单中的文件格式的一些指示,以便在开发自定义格式时,可以以相同的方式指示它.我们的自定义格式在 Windows XP、Windows Vista 和 Windows 7 中运行良好,但由于某些原因,较新的开始菜单设计排除了我们的文件格式,即使它被标记为 IsShortcut
与 .appref-ms
个文件相同。
这可以吗? :-)
(这不是答案,但可以帮助您进行调查。)
我创建并注册了自己的 shell link 扩展。资源管理器重新启动后,它使用我的扩展并通过 IPropertyStore 接口询问不同的属性。完整日志:
TMyLinkExtension.07BA12F0 is created
TMyLinkExtension.07BA12F0.QueryInterface IID_IShellLinkW out Result=S_OK
TMyLinkExtension.07BA12F0.QueryInterface IID_IInitializeWithFile out Result=S_OK
TMyLinkExtension.07BA12F0.IInitializeWithFile.Initialize started
TMyLinkExtension.07BA12F0.IInitializeWithFile.Initialize in AFileName=C:\Users\Dec\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Total Commander.mylnk
TMyLinkExtension.07BA12F0.IInitializeWithFile.Initialize in AOpenMode=STGM_READ
TMyLinkExtension.07BA12F0.IInitializeWithFile.Initialize out Result=S_OK
TMyLinkExtension.07BA12F0.IInitializeWithFile.Initialize finished
TMyLinkExtension.07BA12F0.QueryInterface IID_IShellLinkW out Result=S_OK
TMyLinkExtension.07BA12F0.QueryInterface IID_IShellLinkDataList out Result=S_OK
TMyLinkExtension.07BA12F0.IShellLinkDataList.GetFlags started
TMyLinkExtension.07BA12F0.IShellLinkDataList.GetFlags out Result=E_NOTIMPL
TMyLinkExtension.07BA12F0.IShellLinkDataList.GetFlags finished
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath started
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath in AFileName=0C1FF058
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath in AFileNameLength=260
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath in @AFindData=0C1FEE08
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath in AFlags=SLGP_RAWPATH
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath out Result=E_NOTIMPL
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath finished
TMyLinkExtension.07BA12F0.QueryInterface IID_IPropertyStore out Result=S_OK
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey=PKEY_AppUserModel_ID (Caption: AppUserModelId, CanonicalName: System.AppUserModel.ID, Type: VT_LPWSTR)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey=PKEY_AppUserModel_PreventPinning (Caption: Prevent pinning, CanonicalName: System.AppUserModel.PreventPinning, Type: VT_BOOL)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out AData.vt=VT_BOOL
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out AData=0
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=S_OK
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey={9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 23 (Caption: System.AppUserModel.ExcludedFromLauncher, CanonicalName: System.AppUserModel.ExcludedFromLauncher, Type: VT_BOOL)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out AData.vt=VT_BOOL
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out AData=0
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=S_OK
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey={9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 14 (Caption: Host environment, CanonicalName: System.AppUserModel.HostEnvironment, Type: VT_UI4)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey=PKEY_AppUserModel_StartPinOption (Caption: Start pin option, CanonicalName: System.AppUserModel.StartPinOption, Type: VT_UI4)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey={9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 18 (Caption: Installed by, CanonicalName: System.AppUserModel.InstalledBy, Type: VT_UI4)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey=PKEY_AppUserModel_IsDualMode (Caption: Is dual mode, CanonicalName: System.AppUserModel.IsDualMode, Type: VT_BOOL)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey=PKEY_Link_Arguments (Caption: Arguments, CanonicalName: System.Link.Arguments, Type: VT_LPWSTR)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0 is destroyed
我尝试使用不同的值,但仍然找不到在开始菜单中显示我的 1.mylnk 文件的方法,但也许此日志会对您有所帮助。
要在 Windows 10 开始菜单中显示 link,必须实施 IPropertyStore.GetValue
并且 return PKEY_AppUserModel_ID
属性 的一些唯一字符串.
要在 Windows 10 开始菜单中显示图标,必须实施 IExtractIconW.GetIconLocation
并且注册表项的所有者具有 CLSID class(即 HKEY_CLASSES_ROOT\CLSID{42465C3A-83D3 -4310-B27D-F271DE372764}) 必须是 "NT Service\TrustedInstaller"
这是示例实现(增强的 Jonathan Gilbert 代码):
https://github.com/publee/CustomShortcutFileType
Windows 在文件注册中有一个名为 "IsShortcut" 的标志。设置此标志后,文件会自动获得快捷方式图标覆盖,并在其他方面被视为快捷方式(例如,当您右键单击并 select "Create Shortcut" 时,它只是复制文件而不是生成 .lnk 文件)。 Microsoft 将此功能用于 ClickOnce 应用程序引用(扩展名 .appref-ms
)。
我们将此功能用于我们自己软件的自定义快捷方式文件类型,我们发现自 Windows 10(或可能 Windows 8)以来,我们的自定义快捷方式不出现在开始菜单中。开始菜单当然列出了.lnk
个文件,它也包括了.appref-ms
个文件,但是我们自己的文件格式,其注册方式与.appref-ms
个文件,已从“开始”菜单中排除。快捷方式文件实际存在于“开始”菜单文件夹结构 (%APPDATA%\Microsoft\Windows\Start Menu\Programs
) 中,但会被 Windows 资源管理器忽略。同一目录中的其他快捷方式类型(.lnk
和 .appref-ms
)会显示。
我正在寻找的是 Windows Explorer 如何确定它将包含在“开始”菜单中的文件格式的一些指示,以便在开发自定义格式时,可以以相同的方式指示它.我们的自定义格式在 Windows XP、Windows Vista 和 Windows 7 中运行良好,但由于某些原因,较新的开始菜单设计排除了我们的文件格式,即使它被标记为 IsShortcut
与 .appref-ms
个文件相同。
这可以吗? :-)
(这不是答案,但可以帮助您进行调查。)
我创建并注册了自己的 shell link 扩展。资源管理器重新启动后,它使用我的扩展并通过 IPropertyStore 接口询问不同的属性。完整日志:
TMyLinkExtension.07BA12F0 is created
TMyLinkExtension.07BA12F0.QueryInterface IID_IShellLinkW out Result=S_OK
TMyLinkExtension.07BA12F0.QueryInterface IID_IInitializeWithFile out Result=S_OK
TMyLinkExtension.07BA12F0.IInitializeWithFile.Initialize started
TMyLinkExtension.07BA12F0.IInitializeWithFile.Initialize in AFileName=C:\Users\Dec\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Total Commander.mylnk
TMyLinkExtension.07BA12F0.IInitializeWithFile.Initialize in AOpenMode=STGM_READ
TMyLinkExtension.07BA12F0.IInitializeWithFile.Initialize out Result=S_OK
TMyLinkExtension.07BA12F0.IInitializeWithFile.Initialize finished
TMyLinkExtension.07BA12F0.QueryInterface IID_IShellLinkW out Result=S_OK
TMyLinkExtension.07BA12F0.QueryInterface IID_IShellLinkDataList out Result=S_OK
TMyLinkExtension.07BA12F0.IShellLinkDataList.GetFlags started
TMyLinkExtension.07BA12F0.IShellLinkDataList.GetFlags out Result=E_NOTIMPL
TMyLinkExtension.07BA12F0.IShellLinkDataList.GetFlags finished
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath started
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath in AFileName=0C1FF058
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath in AFileNameLength=260
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath in @AFindData=0C1FEE08
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath in AFlags=SLGP_RAWPATH
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath out Result=E_NOTIMPL
TMyLinkExtension.07BA12F0.IShellLinkW.GetPath finished
TMyLinkExtension.07BA12F0.QueryInterface IID_IPropertyStore out Result=S_OK
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey=PKEY_AppUserModel_ID (Caption: AppUserModelId, CanonicalName: System.AppUserModel.ID, Type: VT_LPWSTR)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey=PKEY_AppUserModel_PreventPinning (Caption: Prevent pinning, CanonicalName: System.AppUserModel.PreventPinning, Type: VT_BOOL)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out AData.vt=VT_BOOL
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out AData=0
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=S_OK
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey={9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 23 (Caption: System.AppUserModel.ExcludedFromLauncher, CanonicalName: System.AppUserModel.ExcludedFromLauncher, Type: VT_BOOL)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out AData.vt=VT_BOOL
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out AData=0
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=S_OK
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey={9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 14 (Caption: Host environment, CanonicalName: System.AppUserModel.HostEnvironment, Type: VT_UI4)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey=PKEY_AppUserModel_StartPinOption (Caption: Start pin option, CanonicalName: System.AppUserModel.StartPinOption, Type: VT_UI4)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey={9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 18 (Caption: Installed by, CanonicalName: System.AppUserModel.InstalledBy, Type: VT_UI4)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey=PKEY_AppUserModel_IsDualMode (Caption: Is dual mode, CanonicalName: System.AppUserModel.IsDualMode, Type: VT_BOOL)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue started
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue in AKey=PKEY_Link_Arguments (Caption: Arguments, CanonicalName: System.Link.Arguments, Type: VT_LPWSTR)
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue out Result=E_INVALIDARG
TMyLinkExtension.07BA12F0.IPropertyStore.GetValue finished
TMyLinkExtension.07BA12F0 is destroyed
我尝试使用不同的值,但仍然找不到在开始菜单中显示我的 1.mylnk 文件的方法,但也许此日志会对您有所帮助。
要在 Windows 10 开始菜单中显示 link,必须实施 IPropertyStore.GetValue
并且 return PKEY_AppUserModel_ID
属性 的一些唯一字符串.
要在 Windows 10 开始菜单中显示图标,必须实施 IExtractIconW.GetIconLocation
并且注册表项的所有者具有 CLSID class(即 HKEY_CLASSES_ROOT\CLSID{42465C3A-83D3 -4310-B27D-F271DE372764}) 必须是 "NT Service\TrustedInstaller"
这是示例实现(增强的 Jonathan Gilbert 代码): https://github.com/publee/CustomShortcutFileType