1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Runtime.InteropServices;
  6. using System.Drawing;
  7. using System.Windows.Forms;
  8. using Microsoft.Win32;
  9. using System.IO;
  10.  
  11. namespace SingleXZ
  12. {
  13. class FullScreenClass
  14. {
  15. public static string CodePath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;//获取当前应用程序完整路径
  16. public const int SPI_SETWORKAREA = ;
  17. public const int SPI_GETWORKAREA = ;
  18. public const int SW_HIDE = 0x00;
  19. public const int SW_SHOW = 0x0001;
  20. public const int SPIF_UPDATEINIFILE = 0x01;
  21. public const int WM_CLOSE = 0x10;
  22. [DllImport("coredll.dll", EntryPoint = "FindWindow")]
  23. private static extern IntPtr FindWindow(string lpWindowName, string lpClassName);
  24. [DllImport("coredll.dll", EntryPoint = "ShowWindow")]
  25. private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
  26. [DllImport("coredll.dll", EntryPoint = "SystemParametersInfo")]
  27. private static extern int SystemParametersInfo(int uAction, int uParam, ref Rectangle lpvParam, int fuWinIni);
  28. [DllImport("coredll.dll", EntryPoint = "SystemParametersInfo")]
  29. private static extern bool IsWindowVisible(IntPtr hwnd);
  30. [DllImport("coredll.dll", EntryPoint = "PostMessage")]
  31. public static extern int PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
  32. [DllImport("coredll.dll", EntryPoint = "CreateMutex", SetLastError = true)]
  33. public static extern IntPtr CreateMutex(IntPtr lpMutexAttributes, bool InitialOwner, string MutexName);
  34.  
  35. [DllImport("coredll.dll", EntryPoint = "ReleaseMutex", SetLastError = true)]
  36. public static extern bool ReleaseMutex(IntPtr hMutex);
  37.  
  38. private const int ERROR_ALREADY_EXISTS = ;
  39. /// <summary>
  40. /// 设置全屏或取消全屏
  41. /// </summary>
  42. /// <param name="fullscreen">true:全屏 false:恢复</param>
  43. /// <param name="rectOld">设置的时候,此参数返回原始尺寸,恢复时用此参数设置恢复</param>
  44. /// <returns>设置结果</returns>
  45. public static bool SetFullScreen(bool fullscreen, ref Rectangle rectOld)
  46. {
  47. IntPtr Hwnd = FindWindow("HHTaskBar", null);
  48. if (Hwnd == IntPtr.Zero) return false;
  49. if (fullscreen)
  50. {
  51. ShowWindow(Hwnd, SW_HIDE);
  52. Rectangle rectFull = Screen.PrimaryScreen.Bounds;
  53. SystemParametersInfo(SPI_GETWORKAREA, , ref rectOld, SPIF_UPDATEINIFILE);//get
  54. SystemParametersInfo(SPI_SETWORKAREA, , ref rectFull, SPIF_UPDATEINIFILE);//set
  55. }
  56. else
  57. {
  58. ShowWindow(Hwnd, SW_SHOW);
  59. SystemParametersInfo(SPI_SETWORKAREA, , ref rectOld, SPIF_UPDATEINIFILE);
  60. }
  61. return true;
  62. }
  63.  
  64. public static void KillMessageBox(string sCaption)
  65. {
  66. IntPtr ptr = FindWindow(null, sCaption);
  67. if (ptr != IntPtr.Zero)
  68. PostMessage(ptr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
  69. }
  70.  
  71. //程序只能运行一次
  72. public static bool IsExist()
  73. {
  74. string strAppName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
  75. IntPtr hMutex = CreateMutex(IntPtr.Zero, true, strAppName);
  76. if (hMutex == IntPtr.Zero)
  77. throw new ApplicationException("Failure creating mutex: " + Marshal.GetLastWin32Error().ToString("X"));
  78.  
  79. if (Marshal.GetLastWin32Error() == ERROR_ALREADY_EXISTS)
  80. {
  81. ReleaseMutex(hMutex);
  82. return true;
  83. }
  84. return false;
  85. }
  86.  
  87. public static void AutoRun()
  88. {
  89. using (RegistryKey key = Registry.LocalMachine.OpenSubKey("init", true))
  90. {
  91. key.SetValue("Launch70", CodePath);
  92. }
  93. }
  94.  
  95. public static void DesktopLink()
  96. {
  97. //根据自己桌面路径写 有些事desktop 有些事桌面
  98. string PathGPRSTrue = "\\Windows\\桌面\\烟支·滤棒吸阻测试仪.lnk";
  99. //if (!File.Exists(PathGPRSTrue)) 如果存在就不想重新写就不用注释(路径不固定这个还是注释掉好点)
  100. {
  101. //File.Copy(PathGPRS, PathGPRSTrue, true);
  102. try
  103. {
  104. string text = (CodePath.Length + ).ToString() + "#\"" + CodePath + "\"";
  105. byte[] buf = new byte[text.Length];
  106. buf = System.Text.Encoding.GetEncoding().GetBytes(text.Substring(, text.Length));
  107. FileStream fs = new FileStream(PathGPRSTrue, FileMode.OpenOrCreate);
  108. fs.Write(buf, , buf.Length);
  109. fs.Close();
  110. fs = null;
  111. }
  112. catch (System.Exception ex)
  113. {
  114.  
  115. }
  116. }
  117. }
  118. }
  119. }

wince c# 创建桌面快捷方式 自动启动 只运行一次 全屏显示的更多相关文章

  1. wince c# 创建桌面快捷方式 .

    static void Create() { string PathGPRS = System.IO.Path.GetDirectoryName(System.Reflection.Assembly. ...

  2. 在ubuntu系统中给filezilla创建桌面快捷方式

    filezilla是一款开源的ftp客户端,当然他们也有服务端,这里以filezilla客户端为例创建快捷方式!默认情况下,ubuntu将自动安装的软件快捷方式保存在/usr/share/applic ...

  3. Ubuntu创建桌面快捷方式

    默认情况下,ubuntu会将自动安装的软件快捷方式保存在/usr/share/applications目录下,如果我们要创建桌面快捷方式,只需要右键-复制-桌面 就Ok,如图: 上面的方法是通过系统自 ...

  4. 在Ubuntu上安装Intellij IDEA并创建桌面快捷方式

    环境信息 版本号 Ubuntu 18.04 LTS Intellij IDEA 2019.1.3 1.首先从官网获取安装包 官方下载地址传送门 然后我就在下载目录下得到了tar.gz的包 2.接下来开 ...

  5. 解决Inno Setup制作安装包无法创建桌面快捷方式的问题

    转自:http://yedward.net/?id=104 昨天想把个java程序做成exe安装软件,然后就去下载了Inno Setup这个软件安装包制作软件,Inno Setup这个软件确实非常好用 ...

  6. Windows中创建桌面快捷方式

    Windows中创建桌面快捷方式 -------------- -------------- -------------- --------------

  7. WPF 创建桌面快捷方式

    #region 创建桌面快捷方式 string deskTop = System.Environment.GetFolderPath(System.Environment.SpecialFolder. ...

  8. C#创建桌面快捷方式 和 开机启动

              /// <summary>         /// 创建桌面快捷方式 2010-11-25         /// </summary>         p ...

  9. android 为应用程序创建桌面快捷方式技巧分享

    手机装的软件过多,找起来很不方便,所以在主页面有一个快捷方式的话会很不错的,本文将介绍如何实现,需要了解跟多的朋友可以参考下     我们开发一款软件后,如果手机装的软件过多,去翻的话会很难翻的,所以 ...

随机推荐

  1. elementary os 0.4.1下编译GCC-7.1源码并安装成功

    参考文章:http://www.2cto.com/os/201402/281131.html 前几天为了图个新鲜,安装了elementary os 0.4.1,的确是一股清流,可惜的是gcc版本觉得有 ...

  2. Android系统默认输入法的修改为搜狗输入法

    1.  frameworks\base\packages\SettingsProvider\res\values\defaults.xml 文件中修改默认输入法为搜狗输入法 <stringnam ...

  3. LightOJ 1140: How Many Zeroes? (数位DP)

    当前数位DP还不理解的点: 1:出口用i==0的方式 2:如何省略状态d(就是枚举下一个数的那个状态.当然枚举还是要的,怎么把空间省了) 总结: 1:此类DP,考虑转移的时候,应当同时考虑查询时候的情 ...

  4. hdu3947 给一些已知(需费用)路径去覆盖一些边 //预先加灌法费用流

    River Problem 题意:一个有向树(河流),只有一个汇点1,每条边只有一个出度.有些河道有污染指数xi,必需要治理,有m段路径,可以去覆盖这些,每被覆盖一次,xi降低响应值. :即 给出一些 ...

  5. LeetCode OJ--ZigZag Conversion

    https://oj.leetcode.com/problems/zigzag-conversion/ 将字符串Z形字排列后,再重新一行一行输出. 可以找到每一行字符位置的规律,然后填充进去. 敲代码 ...

  6. Linux VFS

    翻译自Linux文档中的vfs.txt 介绍 VFS(Virtual File System)是内核提供的文件系统抽象层,其提供了文件系统的操作接口,可以隐藏底层不同文件系统的实现. Directir ...

  7. python中执行shell命令的几个方法

    1.os.system() a=os.system("df -hT | awk 'NR==3{print $(NF-1)}'") 该命令会在页面上打印输出结果,但变量不会保留结果, ...

  8. Java RandomAccessFile类

    RandomAccessFile类是Java中操作文件内容功能最强大的类,既可以读,也可以写. RandomAccessFile支持随机访问,可以直接访问文件的任意位置,在文件的任意位置读写数据.如果 ...

  9. Android-TextView属性ellipsize多行失效的解决思路

    多余文字显示省略号的常规做法 android:ellipsize="end" //省略号显示在末尾 android:ellipsize="middle" //省 ...

  10. kafka生产者客户端

    kafka的生产者 1. 生产者客户端开发 ​ 熟悉kafka的朋友都应该知道kafka客户端有新旧版本,老版本采用scala编写,新版本采用java编写.随着kafka版本的升级,旧版本客户端已经快 ...