前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >C# WinForm实现自动更新程序之客户端的示例代码

C# WinForm实现自动更新程序之客户端的示例代码

原创
作者头像
用户7718188
发布2022-11-06 20:17:40
8150
发布2022-11-06 20:17:40
举报
文章被收录于专栏:高级工程司高级工程司

实现代码

//更新程序

namespace AutoUpdate {

static class Program {

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main(string[] args) {

if(args.Length != 1) {

return;

}

var arg = args[0].Split("|*|");

if(arg.Length == 0) {

return;

}

string runPath = arg[0];

string procesName = arg[1];

Process[] processes = Process.GetProcesses();

foreach(Process process in processes) {

if(process.ProcessName == procesName) {

process.Kill(true);

}

}

Application.SetHighDpiMode(HighDpiMode.SystemAware);

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Form_update(runPath));

}

}

}

public static class ImageEx {

/// <summary>

/// 旋转图片

/// </summary>

/// <param name="image"></param>

/// <param name="angle"></param>

/// <returns></returns>

public static Image RotateImage(this Image image, float angle) {

if(image == null)

throw new ArgumentNullException("image");

float dx = image.Width / 2.0f;

float dy = image.Height / 2.0f;

Bitmap rotatedBmp = new Bitmap(image.Width, image.Height);

rotatedBmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);

Graphics g = Graphics.FromImage(rotatedBmp);

g.TranslateTransform(dx, dy);

g.RotateTransform(angle);

g.TranslateTransform(-dx, -dy);

g.DrawImage(image, new PointF(0, 0));

g.Dispose();

return rotatedBmp;

}

}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 实现代码
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档