C#编程
文章平均质量分 63
our2848884
我是一只螃蟹……
展开
-
【转】在C#中隐藏主窗口的方法
要求:在程序启动的时候主窗口隐藏,只在系统托盘里显示一个图标。 一直以来采用的方法都是设置窗口的ShowInTaskBar=false, WindowState=Minimized。但是偶然发现尽管这样的方法可以使主窗口隐藏不见,但是在用Alt+Tab的时候却可以看见这个程序的图标并把这个窗口显示出来。因此这种方法其实并不能满足要求。 方法一: 重写setVisibleCore方法 prot原创 2017-04-17 15:16:03 · 331 阅读 · 0 评论 -
C#中的BeforeFieldInit
今天学习设计模式中的单例模式,无意间发现了这个标志BeforeFieldInit。于是简单地搜索了一下,总结出如下内容。原创 2017-06-06 22:48:20 · 1203 阅读 · 2 评论 -
【原创】在Release与Debug两种模式下访问文件的相对路径区别
近日,在编写一个小程序的时候,发现一个问题,就是在Debug和Release模式下访问文件的路径不同。代码如下: try { //下面是调用外部程序的代码 ProcessStartInfo Info = new ProcessStartInfo();原创 2017-04-17 15:17:17 · 2954 阅读 · 0 评论 -
【转】C#检测目标机器上是否安装Microsoft .NETFramework平台
参考文章http://www.cnblogs.com/hanfeng/archive/2005/03/03/112246.html http://liuluanqing.blog.ccidnet.com/blog-htm-do-showone-uid-16196-type-blog-itemid-128023.html 第一步:引用空间//系统默认空间添加using System;//添加对注册表原创 2017-04-17 15:17:12 · 1559 阅读 · 0 评论 -
【转】C#.NET使用AnimateWindow制作淡入淡出特殊效果的窗体
首先, 需要添加 using System.Runtime.InteropServices; 其次, #region 动画启动窗体 [DllImportAttribute("user32.dll")] private static extern bool AnimateWindow(IntPtr hwnd, int dwTime原创 2017-04-17 15:17:07 · 2479 阅读 · 0 评论 -
【转】[C#.NET][VB.NET] 用 Win32 API 控制 外部應用程式選單
1.這並不是用SendKey所組成的,所以不管應用程式是否在最上層,都能控制的到。 2.匯入 System.Runtime.InteropServices 及 System.Threading 命名空間 3.選單控制主要由下列三隻API組成 [DllImport("user32.dll", EntryPoint = "GetMenu")] public st原创 2017-04-17 15:16:57 · 471 阅读 · 0 评论 -
C# 调用外部程序
用进程启动的方法在C#中启动了一个外部应用程序,有没有办法来隐藏这个exe文件using System.Diagnostics;C# codeProcessStartInfo info = new ProcessStartInfo();info.FileName = "notepad.exe";info.WindowStyle = ProcessWindowStyle.Hidden;Proce原创 2017-04-17 15:16:54 · 301 阅读 · 0 评论 -
【转】C#启动另一应用程序
1、启动应用程序 System.Diagnostics.Process pro = new System.Diagnostics.Process(); pro.StartInfo.FileName = "C:\\Program Files\\Winsoft\\WinMain.exe"; pro.Start();//关键 2、启动网页 System.Diagnostics.Process pr原创 2017-04-17 15:16:47 · 1181 阅读 · 0 评论 -
【转】C#启动外部应用程序
C#调用外部程序引用:System.Diagnostics.Process// using System.Diagnostics;private string appName = "calc.exe";/// /// 1. 启动外部程序,不等待其退出/// private void button1_Click(object sender, EventArgs e){ Process.Start原创 2017-04-17 15:16:39 · 1719 阅读 · 0 评论 -
C#调用外部应用程序
演示说明 此示例演示如何用C#代码调用记事本程序(Notepad.exe)。主程序等待7秒钟,如果用户没有关闭记事本程序,则主程序强制关闭。示例代码using System; using System.Collections.Generic; using System.Text; // 需要引用的命名空间。 using System.Diagnostics; names原创 2017-04-17 15:16:35 · 1119 阅读 · 0 评论 -
C#中子线程修改主线程中textBox的内容
在编写小软件的过程中,用到了线程操作。但是其中有一个问题是,创建的子线程想修改主程序的textBox的内容,原先的想法就是在子进程调用的函数中直接修改主程序的textBox属性,但是得到的结果是:程序崩溃。原因是线程间进行了不安全的调用……代码如下: private void downloadFile() { DownloadClass dd原创 2017-04-17 15:16:27 · 11915 阅读 · 0 评论 -
关于StreamReader的ReadLine中Trim的使用
今天写了一段小程序,用到了StreamReader的ReadLine函数,结果遇到不明错误,程序自动中止,部分代码如下: string temp; temp = fs.ReadLine().Trim(); while (temp!=null) { dd.StrUrl = tem原创 2017-04-17 15:16:22 · 2554 阅读 · 1 评论 -
C#播放背景音乐常用的四种方式
C#播放背景音乐通常有四种方式: 1.播放系统事件声音 2.使用System.Media.SoundPlayer播放wav 3.使用MCI Command String多媒体设备程序接口播放mp3,avi等 4.使用axWindowsMediaPlayer的COM组件来播放 1.播放系统事件声音 System.Media.SystemSound原创 2017-04-17 15:16:13 · 592 阅读 · 0 评论 -
C# 中如何获得屏幕宽度和高度
Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(this);//int width1 = ScreenArea.Width; //屏幕宽度 int height1 = ScreenArea.Height; //屏幕高度this.Location = new System.Drawing.Point(S_width原创 2017-04-17 15:16:09 · 3502 阅读 · 0 评论 -
CLR via C#读书笔记 - C#中使用as操作符的好处
使用as操作符的好处就是提升代码性能。原创 2017-06-18 17:06:54 · 507 阅读 · 0 评论