Skip to content

Commit

Permalink
优化 管理员权限下添加磁贴闪烁的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
XIU2 committed Sep 15, 2020
1 parent 01f4fcf commit 7bd4ab4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Form.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 20 additions & 11 deletions Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
using System.Windows.Forms;
using System.Diagnostics;
using System.Xml.Linq;
using Microsoft.Win32;
using WebClient_cs;
using FileDropAdmin_cs;
using AppConfig_cs;
using Other_cs;
using Registry_cs;


namespace 磁贴美化小工具
{
public partial class Form : System.Windows.Forms.Form
Expand Down Expand Up @@ -459,10 +457,16 @@ private void Add_Tile_Dll() // 固定磁贴
{
ProcessStartInfo Tile = new ProcessStartInfo
{
FileName = "runas.exe",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = "/trustlevel:0x20000" + '"' + Application.StartupPath + @"\syspin.dll " + @"\" + '"' + TextBox_程序路径.Text + @"\" + '"' + " 51201" + '"'
//FileName = "runas.exe",
FileName = Application.StartupPath + @"\syspin.dll",
//WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
CreateNoWindow = true,
Verb = "explorer",
//Arguments = "/trustlevel:0x20000 " + '"' + @"\" + '"' + Application.StartupPath + @"\syspin.dll" + @"\" + '"' + " " + @"\" + '"' + TextBox_程序路径.Text + @"\" + '"' + " 51201" + '"'
Arguments = '"' + TextBox_程序路径.Text + '"' + " 51201"
};
//Debug.Print(Tile.Arguments);
Process.Start(Tile);
}
else
Expand Down Expand Up @@ -496,7 +500,7 @@ private void Button_查看_Click(object sender, EventArgs e) // 显示并定位
{
if (TextBox_程序路径.Text != "" && System.IO.File.Exists(TextBox_程序路径.Text))
{
_ = Process.Start("explorer.exe", "/select," + TextBox_程序路径.Text);
_ = Process.Start("explorer", "/select," + TextBox_程序路径.Text);
}
}

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

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

private void Button_自动检查更新_Click(object sender, EventArgs e) // 自动检查更新
Expand Down Expand Up @@ -669,26 +673,31 @@ private void TextBox_程序路径_TextChanged(object sender, EventArgs e) // 输
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);
}
// 如果找到了磁贴快捷方式,就设置全局变量 快捷方式文件名、快捷方式路径
if (Temp_Shortcut_Path != "")
if (Temp_Shortcut_Path != null)
{
Old_Shortcut_Path = Temp_Shortcut_Path;
Debug.Print(Old_Shortcut_Path);
//Debug.Print(Old_Shortcut_Path);
Temp_Shortcut_Name = Path.GetFileNameWithoutExtension(Temp_Shortcut_Path);
Debug.Print(Temp_Shortcut_Name);
//Debug.Print(Temp_Shortcut_Name);
}
else
{
Old_Shortcut_Path = Temp_Shortcut_Name = "";
}
// 如果快捷方式文件名为空,则磁贴名称设置为程序文件名
if(Temp_Shortcut_Name != "")
if (Temp_Shortcut_Name != "")
{
TextBox_磁贴名称.Text = Temp_Shortcut_Name;
if (TextBox_磁贴名称.Text == "")
{
TextBox_磁贴名称.Text = Path.GetFileNameWithoutExtension(TextBox_程序路径.Text);
}
}
else
{
TextBox_磁贴名称.Text = Path.GetFileNameWithoutExtension(TextBox_程序路径.Text);
}
Debug.Print("333" + TextBox_磁贴名称.Text);
// 设置程序配置文件路径
Config_Path = Path.GetDirectoryName(TextBox_程序路径.Text) + @"\" + Path.GetFileNameWithoutExtension(TextBox_程序路径.Text) + ".VisualElementsManifest.xml";
Debug.Print(Config_Path);
Expand Down
3 changes: 3 additions & 0 deletions 磁贴美化小工具.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
<StartArguments>
</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<RemoteDebugEnabled>false</RemoteDebugEnabled>
</PropertyGroup>
</Project>

0 comments on commit 7bd4ab4

Please sign in to comment.