mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
Compare commits
3 Commits
feat/1100
...
feat/taskb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
676fe87f04 | ||
|
|
2056fa8f4d | ||
|
|
47debe42ec |
@@ -20,23 +20,23 @@ internal sealed partial class ShellLinkInterop : IShellLinkInterop
|
||||
|
||||
public async ValueTask<bool> TryCreateDesktopShoutcutForElevatedLaunchAsync()
|
||||
{
|
||||
string targetLogoPath = Path.Combine(runtimeOptions.DataFolder, "ShellLinkLogo.ico");
|
||||
string elevatedLauncherPath = Path.Combine(runtimeOptions.DataFolder, "Snap.Hutao.Elevated.Launcher.exe");
|
||||
|
||||
try
|
||||
{
|
||||
Uri sourceLogoUri = "ms-appx:///Assets/Logo.ico".ToUri();
|
||||
StorageFile iconFile = await StorageFile.GetFileFromApplicationUriAsync(sourceLogoUri);
|
||||
await iconFile.OverwriteCopyAsync(targetLogoPath).ConfigureAwait(false);
|
||||
Uri elevatedLauncherUri = "ms-appx:///Snap.Hutao.Elevated.Launcher.exe".ToUri();
|
||||
StorageFile launcherFile = await StorageFile.GetFileFromApplicationUriAsync(elevatedLauncherUri);
|
||||
await launcherFile.OverwriteCopyAsync(elevatedLauncherPath).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return UnsafeTryCreateDesktopShoutcutForElevatedLaunch(targetLogoPath);
|
||||
return UnsafeTryCreateDesktopShoutcutForElevatedLaunch(elevatedLauncherPath);
|
||||
}
|
||||
|
||||
private unsafe bool UnsafeTryCreateDesktopShoutcutForElevatedLaunch(string targetLogoPath)
|
||||
private unsafe bool UnsafeTryCreateDesktopShoutcutForElevatedLaunch(string elevatedLauncherPath)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -44,16 +44,9 @@ internal sealed partial class ShellLinkInterop : IShellLinkInterop
|
||||
HRESULT hr = CoCreateInstance(in ShellLink.CLSID, default, CLSCTX.CLSCTX_INPROC_SERVER, in IShellLinkW.IID, out IShellLinkW* pShellLink);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
pShellLink->SetPath($"shell:AppsFolder\\{runtimeOptions.FamilyName}!App");
|
||||
pShellLink->SetPath(elevatedLauncherPath);
|
||||
pShellLink->SetArguments(runtimeOptions.FamilyName);
|
||||
pShellLink->SetShowCmd(SHOW_WINDOW_CMD.SW_NORMAL);
|
||||
pShellLink->SetIconLocation(targetLogoPath, 0);
|
||||
|
||||
if (SUCCEEDED(pShellLink->QueryInterface(in IShellLinkDataList.IID, out IShellLinkDataList* pShellLinkDataList)))
|
||||
{
|
||||
pShellLinkDataList->GetFlags(out uint flags);
|
||||
pShellLinkDataList->SetFlags(flags | (uint)SHELL_LINK_DATA_FLAGS.SLDF_RUNAS_USER);
|
||||
pShellLinkDataList->Release();
|
||||
}
|
||||
|
||||
if (SUCCEEDED(pShellLink->QueryInterface(in IPersistFile.IID, out IPersistFile* pPersistFile)))
|
||||
{
|
||||
|
||||
@@ -327,6 +327,10 @@
|
||||
<PackageReference Include="Snap.Hutao.Deployment.Runtime" Version="1.16.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Snap.Hutao.Elevated.Launcher.Runtime" Version="1.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Snap.Hutao.SourceGeneration" Version="1.0.7">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
@@ -70,6 +70,14 @@ internal unsafe struct IShellLinkW
|
||||
}
|
||||
}
|
||||
|
||||
public HRESULT SetArguments(string szArgs)
|
||||
{
|
||||
fixed (char* pszArgs = szArgs)
|
||||
{
|
||||
return ThisPtr->SetArguments((IShellLinkW*)Unsafe.AsPointer(ref this), pszArgs);
|
||||
}
|
||||
}
|
||||
|
||||
internal unsafe readonly struct Vftbl
|
||||
{
|
||||
internal readonly IUnknown.Vftbl IUnknownVftbl;
|
||||
|
||||
Reference in New Issue
Block a user