Skip to content

Commit 7bd4ab4

Browse files
committed
优化 管理员权限下添加磁贴闪烁的问题
1 parent 01f4fcf commit 7bd4ab4

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

Form.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Form.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
using System.Windows.Forms;
66
using System.Diagnostics;
77
using System.Xml.Linq;
8-
using Microsoft.Win32;
98
using WebClient_cs;
109
using FileDropAdmin_cs;
1110
using AppConfig_cs;
1211
using Other_cs;
1312
using Registry_cs;
1413

15-
1614
namespace 磁贴美化小工具
1715
{
1816
public partial class Form : System.Windows.Forms.Form
@@ -459,10 +457,16 @@ private void Add_Tile_Dll() // 固定磁贴
459457
{
460458
ProcessStartInfo Tile = new ProcessStartInfo
461459
{
462-
FileName = "runas.exe",
463-
WindowStyle = ProcessWindowStyle.Hidden,
464-
Arguments = "/trustlevel:0x20000" + '"' + Application.StartupPath + @"\syspin.dll " + @"\" + '"' + TextBox_程序路径.Text + @"\" + '"' + " 51201" + '"'
460+
//FileName = "runas.exe",
461+
FileName = Application.StartupPath + @"\syspin.dll",
462+
//WindowStyle = ProcessWindowStyle.Hidden,
463+
UseShellExecute = false,
464+
CreateNoWindow = true,
465+
Verb = "explorer",
466+
//Arguments = "/trustlevel:0x20000 " + '"' + @"\" + '"' + Application.StartupPath + @"\syspin.dll" + @"\" + '"' + " " + @"\" + '"' + TextBox_程序路径.Text + @"\" + '"' + " 51201" + '"'
467+
Arguments = '"' + TextBox_程序路径.Text + '"' + " 51201"
465468
};
469+
//Debug.Print(Tile.Arguments);
466470
Process.Start(Tile);
467471
}
468472
else
@@ -496,7 +500,7 @@ private void Button_查看_Click(object sender, EventArgs e) // 显示并定位
496500
{
497501
if (TextBox_程序路径.Text != "" && System.IO.File.Exists(TextBox_程序路径.Text))
498502
{
499-
_ = Process.Start("explorer.exe", "/select," + TextBox_程序路径.Text);
503+
_ = Process.Start("explorer", "/select," + TextBox_程序路径.Text);
500504
}
501505
}
502506

@@ -589,7 +593,7 @@ private void Check_RightClickMenu() // 检查是否添加右键菜单
589593

590594
private void Button_查看磁贴目录_Click(object sender, EventArgs e) // 查看磁贴目录
591595
{
592-
_ = Process.Start("explorer.exe", "/e," + System.Environment.GetFolderPath(System.Environment.SpecialFolder.Programs));
596+
_ = Process.Start(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Programs));
593597
}
594598

595599
private void Button_自动检查更新_Click(object sender, EventArgs e) // 自动检查更新
@@ -669,26 +673,31 @@ private void TextBox_程序路径_TextChanged(object sender, EventArgs e) // 输
669673
Temp_Shortcut_Path = File_cs.Shortcut.Get_Shortcut_TargetPath_Array(File_cs.File.File_Enumeration(System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonPrograms), "*.lnk", true), TextBox_程序路径.Text);
670674
}
671675
// 如果找到了磁贴快捷方式,就设置全局变量 快捷方式文件名、快捷方式路径
672-
if (Temp_Shortcut_Path != "")
676+
if (Temp_Shortcut_Path != null)
673677
{
674678
Old_Shortcut_Path = Temp_Shortcut_Path;
675-
Debug.Print(Old_Shortcut_Path);
679+
//Debug.Print(Old_Shortcut_Path);
676680
Temp_Shortcut_Name = Path.GetFileNameWithoutExtension(Temp_Shortcut_Path);
677-
Debug.Print(Temp_Shortcut_Name);
681+
//Debug.Print(Temp_Shortcut_Name);
678682
}
679683
else
680684
{
681685
Old_Shortcut_Path = Temp_Shortcut_Name = "";
682686
}
683687
// 如果快捷方式文件名为空,则磁贴名称设置为程序文件名
684-
if(Temp_Shortcut_Name != "")
688+
if (Temp_Shortcut_Name != "")
685689
{
686690
TextBox_磁贴名称.Text = Temp_Shortcut_Name;
691+
if (TextBox_磁贴名称.Text == "")
692+
{
693+
TextBox_磁贴名称.Text = Path.GetFileNameWithoutExtension(TextBox_程序路径.Text);
694+
}
687695
}
688696
else
689697
{
690698
TextBox_磁贴名称.Text = Path.GetFileNameWithoutExtension(TextBox_程序路径.Text);
691699
}
700+
Debug.Print("333" + TextBox_磁贴名称.Text);
692701
// 设置程序配置文件路径
693702
Config_Path = Path.GetDirectoryName(TextBox_程序路径.Text) + @"\" + Path.GetFileNameWithoutExtension(TextBox_程序路径.Text) + ".VisualElementsManifest.xml";
694703
Debug.Print(Config_Path);

磁贴美化小工具.csproj.user

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
<StartArguments>
55
</StartArguments>
66
</PropertyGroup>
7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
8+
<RemoteDebugEnabled>false</RemoteDebugEnabled>
9+
</PropertyGroup>
710
</Project>

0 commit comments

Comments
 (0)