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 为应用程序创建桌面快捷方式技巧分享
手机装的软件过多,找起来很不方便,所以在主页面有一个快捷方式的话会很不错的,本文将介绍如何实现,需要了解跟多的朋友可以参考下 我们开发一款软件后,如果手机装的软件过多,去翻的话会很难翻的,所以 ...
随机推荐
- 马士兵hadoop第三课:java开发hdfs(转)
马士兵hadoop第一课:虚拟机搭建和安装hadoop及启动 马士兵hadoop第二课:hdfs集群集中管理和hadoop文件操作 马士兵hadoop第三课:java开发hdfs 马士兵hadoop第 ...
- bzoj 4007 树形dp
题目大意 脸哥最近来到了一个神奇的王国,王国里的公民每个公民有两个下属或者没有下属,这种关系刚好组成一个 n 层的完全二叉树.公民 i 的下属是 2 * i 和 2 * i +1.最下层的公民即叶子节 ...
- 【bzoj4031】[HEOI2015]小Z的房间 && 【bzoj4894】天赋 (矩阵树定理)
来两道矩阵树模板: T1:[bzoj4031][HEOI2015]小Z的房间 Description 你突然有了一个大房子,房子里面有一些房间.事实上,你的房子可以看做是一个包含n*m个格子的格状矩形 ...
- javaweb学习总结(十五)——JSP基础语法(转)
任何语言都有自己的语法,JAVA中有,JSP虽然是在JAVA上的一种应用,但是依然有其自己扩充的语法,而且在JSP中,所有的JAVA语句都可以使用. 一.JSP模版元素 JSP页面中的HTML内容称之 ...
- 【POJ3498】March of the Penguins(最大流,裂点)
题意:在靠近南极的某处,一些企鹅站在许多漂浮的冰块上.由于企鹅是群居动物,所以它们想要聚集到一起,在同一个冰块上.企鹅们不想把自己的身体弄湿,所以它们在冰块之间跳跃,但是它们的跳跃距离,有一个上限. ...
- C语言实验报告二
实验一:第11次实验作业报告 题目:方阵循环右移 实验要求:将给定n×n方阵中的每个元素循环向右移m个位置,即将第0.1.⋯.n−1列变换为第n−m.n−m+1.⋯.n−1.0.1.⋯.n−m−1列. ...
- 反汇编角度->C++ const
#include<iostream> #include<stdlib.h> using namespace std; const int &add( const int ...
- html5(拖拽1)
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- [原创][FPGA][IP-Core]altlvds_tx & altlvds_rx
1. 概述 Alter公司的QuartusII软件提供了LVDS发送和接收的IP核供我们使用,其在本质上可以理解为并行-串行数据的转换器.其在官方文档(见附件)上也这样说过.其中的应用场景有告诉AD/ ...
- Arduino可穿戴教程ArduinoIDE新建编辑源文件
Arduino可穿戴教程ArduinoIDE新建编辑源文件 Arduino IDE新建源文件 Arduino IDE启动后默认就新建了一个源文件,如图2.20所示.新建的源文件名称是以sketch_开 ...