- 浏览: 680164 次
- 性别:
- 来自: 沈阳
文章分类
- 全部博客 (270)
- Ant Tool Script (12)
- XMLDigest (5)
- MyEclipse8.6 (1)
- RedHat (5)
- SVNVersionController (4)
- BatOperation (6)
- JspAndFaceWeb (66)
- javaSwing (18)
- PHP (12)
- J2SE (6)
- TestToolAndTestManual (12)
- C# (34)
- Java PatternDesign (20)
- Axis2AndWebService (5)
- ITLive (2)
- DBAndControl (10)
- C/C++ (8)
- Andriod (7)
- Python (7)
- JavaWork (16)
- Android-QA (1)
- Apache-Wicket (1)
- POI (1)
- JQuery (2)
- Struts2 (1)
- Flex&Flash (6)
- sdsdsd (0)
- 1212 (0)
最新评论
-
anayomin:
对九楼继续改进
public static <T> ...
Java List 分页 -
H4X0R:
来学习学习,赞一个
Aqua Data Studio 导出SQL -
yankai0219:
现在出现这个错误 Fatal error: Class 'PH ...
纯PHP搭建Apache+Eclipse+xDebug+PHPUnit+MakeGood -
yankai0219:
您好,我在搭建环境中提示PHPUnit_Framework_T ...
纯PHP搭建Apache+Eclipse+xDebug+PHPUnit+MakeGood -
wilsonchen:
chenhailong 写道wilsonchen 写道chen ...
C# RSA和Java RSA互通
winform 有的时候只能打开一次,下一次不要打开的应用
下面是code
static class ApplicationStart { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { bool ExisFlag = false; System.Diagnostics.Process currentProccess = System.Diagnostics.Process.GetCurrentProcess(); System.Diagnostics.Process[] currentProccessArray = System.Diagnostics.Process.GetProcesses(); foreach (System.Diagnostics.Process p in currentProccessArray) { if (p.ProcessName == currentProccess.ProcessName && p.Id != currentProccess.Id) { ExisFlag = true; } } if (ExisFlag) { return; } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new ModelFileGenerator.View.×××()); } } }
上面是第一种方案
在来看看第二种方案
/// <summary> /// window form show count /// </summary> private const int WS_SHOWNORMAL = 1; [DllImport("User32.dll")] private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow); [DllImport("User32.dll")] private static extern bool SetForegroundWindow(IntPtr hWnd); [DllImport("kernel32.dll")] private static extern IntPtr LoadLibrary(string sLibName); /// <summary> /// application start /// </summary> public static void ApplicationStart() { Process instance = RunningInstance(); if (instance == null) { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); Application.Run(new ×××()); } else { HandleRunningInstance(instance); } } /// <summary> /// application repeat start /// </summary> public static void ApplicationRepeatStart() { Process instance = RunningInstance(); if (instance != null) { HandleRunningInstance(instance); } } /// <summary> /// Running process instance /// </summary> /// <returns>the running process</returns> public static Process RunningInstance() { Process current = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName(current.ProcessName); ////Loop through the running processes in with the same name foreach (Process process in processes) { ////Ignore the current process if (process.Id != current.Id) { ////Make sure that the process is running from the exe file. if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName) { ////Return the other process instance. return process; } } } ////No other instance was found, return null. return null; } /// <summary> /// handle running instance /// </summary> /// <param name="instance">the running process</param> public static void HandleRunningInstance(Process instance) { ////Make sure the window is not minimized or maximized ShowWindowAsync(instance.MainWindowHandle, WS_SHOWNORMAL); ////Set the real instance to foreground window SetForegroundWindow(instance.MainWindowHandle); }
Main函数
public const string APP_NAME = "×××"; private static bool isFirstAppInstance = true; private static Mutex mutex = new Mutex(true, APP_NAME, out isFirstAppInstance); /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { if (isFirstAppInstance) { ApplicationManagerUtil.ApplicationStart(); } else { ApplicationManagerUtil.ApplicationRepeatStart(); } }
好了 如果有什么问题请和我联系
发表评论
-
减少winform的内存使用量
2013-06-01 06:49 1129今天看到有趣的代码,功能主要是减少winform的内存使用量。 ... -
C# Timer运行时,系统时间修改
2012-10-19 15:55 2868今天遇到一个问题: C# Time 运行的时候,将系统时间修 ... -
C# 一步一步的开始
2012-09-09 11:02 0------------------------------- ... -
C# 书写window简单服务
2012-03-30 19:59 1231代码如下: using System.Co ... -
手工添加window 服务依赖
2012-03-29 15:11 1907这里是bat文件 复制就可以添加 ... -
Services do not start and Event ID 7022
2012-03-29 15:07 1385今天遇到一个问题 具体的如题 解决方案: ... -
C# 读2007Excel文件
2012-03-27 13:51 2372今天遇到一个问题: C# ... -
C# 胡乱实现,程序 占用CPU50%
2012-02-28 07:05 3691今天早上看到了编程之美,我很兴奋,大早上看书,有吗? 有木有? ... -
IIS not work because of Com+ Application error or IWAM user not have password
2012-02-24 16:19 1738今天遇到了一个问题。XP的IIS 5.1 安装成功后会出现: ... -
IIS 7.0 HTTP Error 403.14
2012-02-23 13:09 1481刚才碰到一个问题:如题 下面是解决方案: 方法 ... -
C# Chart详细解析(待)
2012-02-07 19:25 54898一年有过去了, 很长时间也没有写什么文章了,准确的说是2个月, ... -
ProcessBar 2种经典实现
2011-12-15 14:05 1128我今天实装了ProcessBar 的两种实现方式 下面 ... -
winform 让事件提前运行
2011-12-15 13:54 1584今天遇到了一个问题,就是让Winform中的事件提前运行的问题 ... -
using C# modify app.config in the run time
2011-12-13 11:19 1322今天在印度的网站上发现一个很经典的代码,也对比了国内的网站的答 ... -
winform 方向键焦点丢失问题(keydown event not work)
2011-12-10 11:47 1923在项目中遇到了,方向键不能被keydown event 捕捉的 ... -
Windows Install SQL Manager Error
2011-11-21 09:52 1063在安装SQL Manager的时候会出现异常,是由于操作系统的 ... -
C# 文件Copy 不包含.svn文件
2011-11-18 11:48 1819今天遇到了C#文件copy的问题 现在写出了解决方案 ... -
实现winform 代码导入dll
2011-11-14 14:48 1479代码如下: [DllImport(" ... -
.net 3.5 Form Chart 解决方案
2011-11-12 16:49 1695刚刚写了一篇关于自己生活的文章,下面写下,最近我一直在做个项目 ... -
Window Form所有组件按主Form扩大
2011-11-08 13:08 1277今天遇到了Form 扩大到问题,写下了如下代码,希望对大家有用 ...
相关推荐
C#Winform实现打开第三方应用程序实例
C#winform窗体应用程序打开文件对话框
C# Winform 自动运行 不用输入密码登录进入桌面可以运行的程序。.Net Framework4.5桌面程序
开发语言C#,.net环境下。C#Winform界面布局设计(左侧菜单)右侧窗口操作。以前做ERP设置的自定义控件。很好用。
另外,C#不但可以开发基于.net的应用程序,也可以开发基于WinForm的程序,这就是区别。 若是单纯以概念来说,你可以把.net当做一个工作平台一般,它是一个开发环境的基底,提供你开发Windows、Web、Mobile、XML......
1)窗口分左右结构,包含菜单、工具栏、树形视图和列表; 2)展示用户目录及其下所有文件夹,点击左边树形视图中的文件夹,右侧列表可显示该文件夹中的子文件夹和文件;...3)对于txt文件,可以双击打开。
C#winform 窗体与Webbrowser控件的相互交互
此代码功能是设置应用程序 只是允许开启一个.EXE 并最前端显示 可以保持程序之前的状态。例如,之前最大化,当你最小化后,在开启新的应用程序 程序会最前段保持最大化显示
C#关闭外部程序
1、创建winfrom应用程序;(或者是控制台项目) 2、在项目中添加一个WCF服务,并实现服务; 3、在需要启动WebService服务的地方启动该服务即可; 二、代码如下: 1、新建一个WCF服务——定义服务接口 ...
C# WinForm程序完全退出的问题解决,需要的朋友可以参考一下
Winform实现窗体内嵌入第三方应用窗体,只需要知道窗体名称,即可将第三方应用的窗体嵌入到自己的程序中,使用WinForm的Panel控件作为其父容器,并且第三方窗体仍然保持原有的功能,如点击,输入等,可以随着自己的...
https://blog.csdn.net/shisuizhe/article/details/54949431?locationNum=6&fps=1根据大佬的博客制作的damo,通过url点击打开winform程序,并传值
winform的文本框中输入一串字符串,点击搜索!即可打开搜索引擎搜索结果!无需进入搜索引擎后再点击按钮!
新版本的Office对于WebBrowser控件意见不能用,这个是调用系统api进行操作,打开速度快,依赖项少,意见测试可用。测试环境 Visual Studio2019+Office2019。
4.2.1 如何制作一个接口程序 80 4.2.2 实现接口程序的信息互传 80 4.2.3 如何将接口程序加载到其他程序中 82 4.2.4 怎样操作RichtextBox控件的选择文本 82 4.2.5 如何获取数据表中字段的描述...
附件中包含一个被抓取句柄的窗体程序,直接打开,用C#源码就能控制抓取句柄的窗体程序,控制窗体上按钮的点击事件,读取textebox数据等等,可直接看出效果
C#窗体嵌套其他应用程序,将foxit reader应用程序嵌套到C#窗体中,并可以打开指定的pdf文件。在win10, VS2013上运行通过。
C# winfrom Windows服务监控exe进程,启动exe窗体应用程序
以XP 系统为例子,程序启动后,打开任务管理器,会看到占用的内存量比较大,你把程序最小化,会发现该程序占用的内存迅速减小到一个很小的值,再恢复你的程序,你会发现内存占用又上升了,但是比你刚启动时的内存...