wince c# 创建桌面快捷方式 自动启动 只运行一次 全屏显示
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.Win32;
using System.IO; namespace SingleXZ
{
class FullScreenClass
{
public static string CodePath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;//获取当前应用程序完整路径
public const int SPI_SETWORKAREA = ;
public const int SPI_GETWORKAREA = ;
public const int SW_HIDE = 0x00;
public const int SW_SHOW = 0x0001;
public const int SPIF_UPDATEINIFILE = 0x01;
public const int WM_CLOSE = 0x10;
[DllImport("coredll.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lpWindowName, string lpClassName);
[DllImport("coredll.dll", EntryPoint = "ShowWindow")]
private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("coredll.dll", EntryPoint = "SystemParametersInfo")]
private static extern int SystemParametersInfo(int uAction, int uParam, ref Rectangle lpvParam, int fuWinIni);
[DllImport("coredll.dll", EntryPoint = "SystemParametersInfo")]
private static extern bool IsWindowVisible(IntPtr hwnd);
[DllImport("coredll.dll", EntryPoint = "PostMessage")]
public static extern int PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
[DllImport("coredll.dll", EntryPoint = "CreateMutex", SetLastError = true)]
public static extern IntPtr CreateMutex(IntPtr lpMutexAttributes, bool InitialOwner, string MutexName); [DllImport("coredll.dll", EntryPoint = "ReleaseMutex", SetLastError = true)]
public static extern bool ReleaseMutex(IntPtr hMutex); private const int ERROR_ALREADY_EXISTS = ;
/// <summary>
/// 设置全屏或取消全屏
/// </summary>
/// <param name="fullscreen">true:全屏 false:恢复</param>
/// <param name="rectOld">设置的时候,此参数返回原始尺寸,恢复时用此参数设置恢复</param>
/// <returns>设置结果</returns>
public static bool SetFullScreen(bool fullscreen, ref Rectangle rectOld)
{
IntPtr Hwnd = FindWindow("HHTaskBar", null);
if (Hwnd == IntPtr.Zero) return false;
if (fullscreen)
{
ShowWindow(Hwnd, SW_HIDE);
Rectangle rectFull = Screen.PrimaryScreen.Bounds;
SystemParametersInfo(SPI_GETWORKAREA, , ref rectOld, SPIF_UPDATEINIFILE);//get
SystemParametersInfo(SPI_SETWORKAREA, , ref rectFull, SPIF_UPDATEINIFILE);//set
}
else
{
ShowWindow(Hwnd, SW_SHOW);
SystemParametersInfo(SPI_SETWORKAREA, , ref rectOld, SPIF_UPDATEINIFILE);
}
return true;
} public static void KillMessageBox(string sCaption)
{
IntPtr ptr = FindWindow(null, sCaption);
if (ptr != IntPtr.Zero)
PostMessage(ptr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
} //程序只能运行一次
public static bool IsExist()
{
string strAppName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
IntPtr hMutex = CreateMutex(IntPtr.Zero, true, strAppName);
if (hMutex == IntPtr.Zero)
throw new ApplicationException("Failure creating mutex: " + Marshal.GetLastWin32Error().ToString("X")); if (Marshal.GetLastWin32Error() == ERROR_ALREADY_EXISTS)
{
ReleaseMutex(hMutex);
return true;
}
return false;
} public static void AutoRun()
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("init", true))
{
key.SetValue("Launch70", CodePath);
}
} public static void DesktopLink()
{
//根据自己桌面路径写 有些事desktop 有些事桌面
string PathGPRSTrue = "\\Windows\\桌面\\烟支·滤棒吸阻测试仪.lnk";
//if (!File.Exists(PathGPRSTrue)) 如果存在就不想重新写就不用注释(路径不固定这个还是注释掉好点)
{
//File.Copy(PathGPRS, PathGPRSTrue, true);
try
{
string text = (CodePath.Length + ).ToString() + "#\"" + CodePath + "\"";
byte[] buf = new byte[text.Length];
buf = System.Text.Encoding.GetEncoding().GetBytes(text.Substring(, text.Length));
FileStream fs = new FileStream(PathGPRSTrue, FileMode.OpenOrCreate);
fs.Write(buf, , buf.Length);
fs.Close();
fs = null;
}
catch (System.Exception ex)
{ }
}
}
}
}
wince c# 创建桌面快捷方式 自动启动 只运行一次 全屏显示的更多相关文章
- wince c# 创建桌面快捷方式 .
static void Create() { string PathGPRS = System.IO.Path.GetDirectoryName(System.Reflection.Assembly. ...
- 在ubuntu系统中给filezilla创建桌面快捷方式
filezilla是一款开源的ftp客户端,当然他们也有服务端,这里以filezilla客户端为例创建快捷方式!默认情况下,ubuntu将自动安装的软件快捷方式保存在/usr/share/applic ...
- Ubuntu创建桌面快捷方式
默认情况下,ubuntu会将自动安装的软件快捷方式保存在/usr/share/applications目录下,如果我们要创建桌面快捷方式,只需要右键-复制-桌面 就Ok,如图: 上面的方法是通过系统自 ...
- 在Ubuntu上安装Intellij IDEA并创建桌面快捷方式
环境信息 版本号 Ubuntu 18.04 LTS Intellij IDEA 2019.1.3 1.首先从官网获取安装包 官方下载地址传送门 然后我就在下载目录下得到了tar.gz的包 2.接下来开 ...
- 解决Inno Setup制作安装包无法创建桌面快捷方式的问题
转自:http://yedward.net/?id=104 昨天想把个java程序做成exe安装软件,然后就去下载了Inno Setup这个软件安装包制作软件,Inno Setup这个软件确实非常好用 ...
- Windows中创建桌面快捷方式
Windows中创建桌面快捷方式 -------------- -------------- -------------- --------------
- WPF 创建桌面快捷方式
#region 创建桌面快捷方式 string deskTop = System.Environment.GetFolderPath(System.Environment.SpecialFolder. ...
- C#创建桌面快捷方式 和 开机启动
/// <summary> /// 创建桌面快捷方式 2010-11-25 /// </summary> p ...
- android 为应用程序创建桌面快捷方式技巧分享
手机装的软件过多,找起来很不方便,所以在主页面有一个快捷方式的话会很不错的,本文将介绍如何实现,需要了解跟多的朋友可以参考下 我们开发一款软件后,如果手机装的软件过多,去翻的话会很难翻的,所以 ...
随机推荐
- c#.net分类上升达人~~~呵呵。。。
原文发布时间为:2008-11-11 -- 来源于本人的百度文章 [由搬家工具导入] 觉得自己蛮无聊的~~~~~~~~~(>_<)~~~~
- Notepad++中常用的插件【转】
转自:http://www.crifan.com/files/doc/docbook/rec_soft_npp/release/htmls/npp_common_plugins.html 1.4. N ...
- llinux 定时器 转载自 http://blog.chinaunix.net/uid-11848011-id-96374.html
这篇文章主要记录我在试图解决如何尽可能精确地在某个特定的时间间隔执行某项具体任务时的思路历程,并在后期对相关的API进行的归纳和总结,以备参考. 问题引出 很多时候,我们会有类似“每隔多长时间执行某项 ...
- HDU 2767:Proving Equivalences(强连通)
题意: 一个有向图,问最少加几条边,能让它强连通 方法: 1:tarjan 缩点 2:采用如下构造法: 缩点后的图找到所有头结点和尾结点,那么,可以这么构造:把所有的尾结点连一条边到头结点,就必然可以 ...
- 小程序-生成一个小程序码画在canvas画布上生成一张图片分享出去
这个需求我遇到过2次.一次是在识别二维码后跳转到其它页面,另一次是识别二维码后进入到生成小程序码的当前页面. 我有一个梦想,就是成为一名黑客!!!!!! 小程序中js wx.request({ ...
- Python内置函数和匿名函数
内容回顾: 1.列表推导式 [变量(加工后的变量) for 变量 in iterable] 循环模式 [变量(加工后的变量) for 变量 in iterable if 条件] 筛选模式 生成器表达式 ...
- babel ---- presets字段设定转码规则
presets字段设定转码规则,官方提供以下的规则集,你可以根据需要安装. # ES2015转码规则 $ npm install --save-dev babel-preset-es2015 # re ...
- HDU 5794 A Simple Chess(杨辉三角+容斥原理+Lucas定理)
题目链接 A Simple Chess 打表发现这其实是一个杨辉三角…… 然后发现很多格子上方案数都是0 对于那写可能可以到达的点(先不考虑障碍点),我们先叫做有效的点 对于那些障碍,如果不在有效点上 ...
- lodash常用
1) Loop for N times // 1. Basic for loop. for(var i = 0; i < 5; i++) { // .... } // 2. Using Arra ...
- Android Glide源码分析
1. 功能介绍 图片加载框架,相对于UniversalImageLoader,Picasso,它还支持video,Gif,SVG格式,支持缩略图请求,旨在打造更好的列表图片滑动体验.Glide有生命周 ...