版博士V2.0程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

347 wiersze
16 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Drawing;
  5. using System.Runtime.InteropServices;
  6. namespace AssistClient
  7. {
  8. public class API
  9. {
  10. [StructLayout(LayoutKind.Sequential)]
  11. public struct COPYDATASTRUCT
  12. {
  13. public IntPtr dwData;
  14. public int cbData;//lpData大小
  15. public IntPtr lpData;
  16. }
  17. public const int WM_COPYDATA = 0x004A;
  18. public const int WM_CLOSE = 0x10;
  19. //定义常数用作函数StretechBlt中正常色彩复制的光栅操作码
  20. public const int Srccopy = 0xCC0020;
  21. //'定义常数用作函数StretechBlt中反色复制的光栅操作码
  22. public const int NotSrccopy = 0x330008;
  23. //定义常数用作函数SetWindowPos中使窗口位于所有窗口最上面一层,避免被其它窗口遮挡
  24. public const int HWND_TOPMOST = -1;
  25. public const int SWP_NOMOVE = 2;
  26. public const int SWP_NOSIZE = 1;
  27. public const int SWP_NOACTIVATE = 0x10;
  28. public const int HWND_TOP = 0;
  29. public const int HWND_NOTOPMOST = -2;
  30. //SetStretchBltMode模式
  31. public const int STRETCH_ANDSCANS = 1;
  32. public const int STRETCH_DELETESCANS = 3;
  33. public const int STRETCH_ORSCANS = 2;
  34. public const int STRETCH_HALFTONE = 4;
  35. //
  36. [DllImport("User32.dll")]
  37. public static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
  38. public const int WS_SHOWNORMAL = 1;
  39. [DllImport("shell32.dll")]
  40. public static extern int ShellExecute(IntPtr hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
  41. [DllImport("user32.dll")]
  42. public static extern IntPtr GetActiveWindow();
  43. [DllImport("user32.dll")]
  44. public static extern IntPtr GetForegroundWindow();
  45. [DllImport("user32.dll")]
  46. public static extern bool IsWindow(IntPtr hwnd);
  47. [DllImport("user32.dll")]
  48. public static extern int GetClassName(IntPtr hwnd, StringBuilder lpClassName, int nMaxCount);
  49. [DllImport("user32.dll")]
  50. public static extern int DrawText(IntPtr hdc, string lpStr, int nCount, RECT lpRect, int wFormat);
  51. public const int DT_CENTER = 0x1;
  52. public const int DT_BOTTOM = 0x8;
  53. public const int DT_SINGLELINE = 0x20;
  54. public const int GWL_STYLE = -16;
  55. public const UInt32 WS_MINIMIZEBOX = 0x20000;
  56. public const UInt32 WS_MAXIMIZEBOX = 0x10000;
  57. public const UInt32 WS_SYSMENU = 0x80000;
  58. public const UInt32 WS_CAPTION = 0xC00000;
  59. public const int GWL_EXSTYLE = -20;
  60. public const int LWA_COLORKEY = 1;
  61. public const int LWA_ALPHA = 2;
  62. public const int WS_EX_LAYERED = 0x80000;
  63. [DllImport("user32.dll")]
  64. public static extern UInt32 GetWindowLong(IntPtr hwnd, int nIndex);
  65. [DllImport("user32.dll")]
  66. public static extern UInt32 SetWindowLong(IntPtr hwnd, int nIndex, UInt32 dwNewLong);
  67. [DllImport("user32.dll")]
  68. public static extern UInt32 SetLayeredWindowAttributes(IntPtr hwnd, int cKey, int bAlpha, int dwFlags);
  69. [DllImport("kernel32.dll", SetLastError = true)]
  70. [return: MarshalAs(UnmanagedType.Bool)]
  71. public static extern bool DeleteFile(string lpFileName);
  72. [DllImport("kernel32.dll", SetLastError = true)]
  73. [return: MarshalAs(UnmanagedType.Bool)]
  74. public static extern bool CopyFile(string lpExistingFileName, string lpNewFileName, bool bFailIfExists);
  75. //窗体拖动
  76. public const UInt32 WM_SYSCOMMAND = 0x112;
  77. public const UInt32 SC_MOVE = 0xF010;
  78. public const UInt32 HTCAPTION = 0x2;
  79. [DllImport("user32.dll")]
  80. public static extern UInt32 ReleaseCapture();
  81. [DllImport("user32.dll")]
  82. public static extern UInt32 SendMessage(IntPtr hWnd, UInt32 wMsg, UInt32 wParam, IntPtr lParam);
  83. [DllImport("user32.dll")]//函数声明,用于将窗口置于最上方
  84. public static extern int SetWindowPos(IntPtr hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
  85. [DllImport("user32.dll")]//函数声明,用于获得整个屏幕的窗口句柄,以作为绘制的源
  86. public static extern IntPtr GetDesktopWindow();
  87. [DllImport("user32.dll")]//函数声明,用于用于获得指定窗口一个设备环境。
  88. public static extern IntPtr GetDC(IntPtr hwnd);
  89. [DllImport("gdi32.dll")]//
  90. public static extern int SetStretchBltMode(IntPtr hdc, int nStretchMode);
  91. [DllImport("gdi32.dll")]//函数声明,用于将屏幕任意位置的一个矩形位置复制到另一个位置并实现镜像翻转
  92. public static extern int StretchBlt(IntPtr hdc, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, int dwRop);
  93. [DllImport("user32.dll")]//函数声明,释放窗口的设备环境
  94. public static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
  95. //最前显示4个
  96. [DllImport("user32.dll")]
  97. public static extern int SetActiveWindow(IntPtr hwnd);
  98. [DllImport("user32.dll")]
  99. public static extern int SetForegroundWindow(IntPtr hwnd);
  100. [DllImport("user32.dll")]
  101. public static extern int SetFocus(IntPtr hwnd);
  102. [DllImport("user32.dll")]
  103. public static extern int BringWindowToTop(IntPtr hwnd);
  104. //
  105. [DllImport("user32.dll")]
  106. public static extern IntPtr LoadCursorFromFile(string lpFileName);
  107. [DllImport("user32.dll")]
  108. public static extern IntPtr SetCursor(IntPtr cursorHandle);
  109. [DllImport("user32.dll")]
  110. public static extern uint DestroyCursor(IntPtr cursorHandle);
  111. public struct POINTAPI
  112. {
  113. public int x;
  114. public int y;
  115. }
  116. [DllImport("user32.dll")]
  117. public static extern int SetCursorPos(int x, int y);
  118. [DllImport("user32.dll")]
  119. public static extern int GetCursorPos(ref POINTAPI lpPoint);
  120. [DllImport("user32.dll")]
  121. public static extern IntPtr GetCursor();
  122. public struct ICONINFO
  123. {
  124. public bool fIcon; // Specifies whether this structure defines an icon or a cursor. A value of TRUE specifies
  125. public Int32 xHotspot; // Specifies the x-coordinate of a cursor's hot spot. If this structure defines an icon, the hot
  126. public Int32 yHotspot; // Specifies the y-coordinate of the cursor's hot spot. If this structure defines an icon, the hot
  127. public IntPtr hbmMask; // (HBITMAP) Specifies the icon bitmask bitmap. If this structure defines a black and white icon,
  128. public IntPtr hbmColor; // (HBITMAP) Handle to the icon color bitmap. This member can be optional if this
  129. }
  130. public struct CURSORINFO
  131. {
  132. public Int32 cbSize;
  133. public Int32 flags;
  134. public Int32 hCursor;
  135. public POINTAPI ptScreenPos;
  136. }
  137. [DllImport("user32.dll", EntryPoint = "GetIconInfo")]
  138. public static extern bool GetIconInfo(IntPtr hIcon, out ICONINFO piconinfo);
  139. [DllImport("user32.dll")]
  140. public static extern bool GetCursorInfo(out CURSORINFO pci);
  141. [DllImport("user32.dll")]
  142. public static extern bool DrawIcon(IntPtr hDC, int X, int Y, IntPtr hIcon);
  143. public const int DI_MASK = 0x0001;
  144. public const int DI_IMAGE = 0x0002;
  145. public const int DI_NORMAL = 0x0003;
  146. public const int DI_COMPAT = 0x0004;
  147. public const int DI_DEFAULTSIZE = 0x0008;
  148. [DllImport("user32.dll")]
  149. public static extern int DrawIconEx(IntPtr hdc, int xLeft, int yTop, IntPtr hIcon, int cxWidth, int cyWidth, int istepIfAniCur, int hbrFlickerFreeDraw, int diFlags);
  150. [DllImport("gdi32.dll")]
  151. public static extern int DeleteObject(IntPtr hObject);
  152. [DllImport("user32.dll")]
  153. public static extern IntPtr WindowFromPoint(int xPoint, int yPoint);
  154. [DllImport("user32.dll")]
  155. public static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId);
  156. [DllImport("kernel32.dll")]
  157. public static extern IntPtr GetCurrentThreadId();
  158. [DllImport("user32.dll")]
  159. public static extern int AttachThreadInput(IntPtr idAttach, IntPtr idAttachTo, bool fAttach);
  160. [DllImport("user32.dll")]
  161. public static extern int MoveWindow(IntPtr hwnd, int x, int y, int nWidth, int nHeight, bool bRepaint);
  162. [DllImport("user32.dll")]
  163. public static extern bool IsZoomed(IntPtr hwnd);//判断窗口是否为最大化
  164. [DllImport("user32.dll")]
  165. public static extern bool IsIconic(IntPtr hwnd);//判断窗口是否为最小化
  166. //控制播放器
  167. [DllImport("user32.dll")]
  168. public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
  169. [DllImport("user32.dll")]
  170. public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
  171. [DllImport("kernel32.dll")]
  172. public static extern void Sleep(int i);
  173. [DllImport("User32.dll", EntryPoint = "PostMessage")]
  174. public static extern int PostMessage(
  175. IntPtr hWnd, // handle to destination window
  176. int Msg, // message
  177. int wParam, // first message parameter
  178. int lParam // second message parameter
  179. );
  180. public const int WM_USER = 0x0400;
  181. public const int WMU_WLQ = WM_USER + 88;
  182. public const int PARA_PLAY = 0x1;
  183. public const int PARA_STOP = 0x2;
  184. public const int PARA_FULL = 0x4;
  185. public const int PARA_MIN = 0x8;
  186. public const int PARA_MAX = 0x10;
  187. public const int PARA_MOVEL = 0x20;
  188. public const int PARA_MOVER = 0x40;
  189. //
  190. //播放器消息命令:
  191. public const int PLAYER_PLAY = WM_USER + 0x0001;//播放
  192. public const int PLAYER_BREAK = WM_USER + 0x0002;//暂停
  193. public const int PLAYER_FULL = WM_USER + 0x0004;//全屏
  194. public const int PLAYER_NOFULL = WM_USER + 0x0008;//退出全屏
  195. public const int PLAYER_STOP = WM_USER + 0x0010;//停止
  196. public const int PLAYER_EXIT = WM_USER + 0x0020;//退出
  197. public const int PLAYER_SHOW = WM_USER + 0x0040;//显示窗体
  198. public const int PLAYER_HIDE = WM_USER + 0x0080;//隐藏窗体
  199. public const int PLAYER_PLAY_FULL = WM_USER + 0x0021;//播放并全屏
  200. public const int PLAYER_BREAK_HIDE = WM_USER + 0x0022;//暂停并隐藏
  201. //
  202. public const int SW_HIDE = 0;
  203. public const int SW_SHOWNORMAL = 1;
  204. public const int SW_NORMAL = 1;
  205. public const int SW_SHOWMINIMIZED = 2;
  206. public const int SW_SHOWMAXIMIZED = 3;
  207. public const int SW_MAXIMIZE = 3;
  208. public const int SW_SHOWNOACTIVATE = 4;
  209. public const int SW_SHOW = 5;
  210. public const int SW_MINIMIZE = 6;
  211. public const int SW_SHOWMINNOACTIVE = 7;
  212. public const int SW_SHOWNA = 8;
  213. public const int SW_RESTORE = 9;
  214. public const int SW_SHOWDEFAULT = 10;
  215. public const int SW_FORCEMINIMIZE = 11;
  216. public const int SW_MAX = 11;
  217. //自定义消息
  218. public const int WM_MOVENEXT = WM_USER + 5;//dsd纸用、电信最初屏幕上签名版本[to副屏]
  219. public const int WM_MOVEFIRST = WM_USER + 6;//dsd纸用、电信最初屏幕上签名版本[to主屏]
  220. public const int WM_MOVENEXT1 = WM_USER + 7;//电信最新[切屏]到副屏
  221. public const int WM_MOVEFIRST1 = WM_USER + 8;//电信最新[签名完成]到主屏
  222. public const int WM_ShowSignWin = WM_USER + 10;//电信最新[打印小票]弹出半透明窗口(扩展屏)
  223. public const int WM_HideSignWin = WM_USER + 11;//电信最新[半透明窗口左上角对号图片按钮](扩展屏)
  224. public const int WM_ShowSignWin2 = WM_USER + 12;//电信最新[打印小票]弹出半透明窗口(主屏)
  225. public const int WM_HideSignWin2 = WM_USER + 13;//电信最新[半透明窗口左上角对号图片按钮](主屏)
  226. public const int WM_LookPrimaryScreen = WM_USER + 20;//电信最新[副屏监视主屏]
  227. public const int WM_UnLookPrimaryScreen = WM_USER + 21;//电信最新[取消副屏监视主屏]
  228. //声明读写INI文件的API函数
  229. [DllImport("kernel32")]
  230. public static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
  231. [DllImport("kernel32")]
  232. public static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
  233. //
  234. public const UInt32 MF_BYPOSITION = 0x400;
  235. public const UInt32 MF_BYCOMMAND = 0x0;
  236. public const UInt32 SC_CLOSE = 0xF060;
  237. public const UInt32 SC_MAXIMIZE = 0xF030;
  238. public const UInt32 SC_MINIMIZE = 0xF020;
  239. public const UInt32 WS_EX_APPWINDOW = 0x40000;
  240. [DllImport("user32.dll")]
  241. public static extern IntPtr GetSystemMenu(IntPtr hwnd, bool bRevert);
  242. [DllImport("user32.dll")]
  243. public static extern int RemoveMenu(IntPtr hMenu, UInt32 nPosition, UInt32 wFlags);
  244. [DllImport("user32.dll")]
  245. public static extern int ModifyMenu(IntPtr hMenu, int nPosition, int wFlags, int wIDNewItem, int lpString);
  246. [DllImport("user32.dll")]
  247. public static extern UInt32 SetWindowText(IntPtr hwnd, string lpString);
  248. public struct RECT
  249. {
  250. public RECT(int _left, int _top, int _right, int _bottom)
  251. {
  252. Left = _left;
  253. Top = _top;
  254. Right = _right;
  255. Bottom = _bottom;
  256. }
  257. public int Left;
  258. public int Top;
  259. public int Right;
  260. public int Bottom;
  261. }
  262. [DllImport("user32.dll")]
  263. public static extern int GetWindowRect(IntPtr hwnd, out API.RECT lpRect);
  264. [DllImport("user32.dll")]
  265. public static extern int ClipCursor(RECT lpRect);
  266. public const int WM_KEYDOWN = 0x100;
  267. public const int WM_KEYUP = 0x101;
  268. //HOT KEY
  269. [DllImport("kernel32.dll")]
  270. public static extern uint GlobalAddAtom(string lpHotKeyName);
  271. [DllImport("user32.dll", SetLastError = true)]
  272. public static extern bool RegisterHotKey(
  273. IntPtr hWnd, //要定义热键的窗口的句柄
  274. uint id, //定义热键ID(不能与其它ID重复)
  275. KeyModifiers fsModifiers, //标识热键是否在按Alt、Ctrl、Shift、Windows等键时才会生效
  276. System.Windows.Forms.Keys vk //定义热键的内容
  277. );
  278. [DllImport("user32.dll", SetLastError = true)]
  279. public static extern bool UnregisterHotKey(
  280. IntPtr hWnd, //要取消热键的窗口的句柄
  281. uint id //要取消热键的ID
  282. );
  283. //定义了辅助键的名称(将数字转变为字符以便于记忆,也可去除此枚举而直接使用数值)
  284. [Flags()]
  285. public enum KeyModifiers
  286. {
  287. None = 0,
  288. Alt = 1,
  289. Ctrl = 2,
  290. Shift = 4,
  291. WindowsKey = 8
  292. }
  293. //====================
  294. [DllImport("user32.dll", SetLastError = true)]
  295. public static extern IntPtr GetParent(IntPtr hWnd);
  296. [DllImport("user32.dll", SetLastError = true)]
  297. public static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
  298. //标题栏厚度
  299. public const int SM_CYCAPTION = 4;
  300. //边框宽度
  301. public const int SM_CYBORDER = 6;
  302. [DllImport("user32.dll", SetLastError = true)]
  303. public static extern int GetSystemMetrics(int nIndex);
  304. [DllImport("kernel32.dll")]
  305. public static extern void OutputDebugString(string lpOutputString);
  306. }
  307. }