Win32.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using System.ComponentModel;
  4. using System.Text;
  5. namespace LYFZ.WinAPI
  6. {
  7. /// <summary>
  8. /// Wind32API声明
  9. /// </summary>
  10. public class Win32
  11. {
  12. public const int GWL_EXSTYLE = -20;
  13. public const int WS_EX_TRANSPARENT = 0x00000020;
  14. public const int WS_EX_LAYERED = 0x00080000;
  15. public const int WM_COPYDATA = 0x004A;
  16. public const int USER = 0x0400;
  17. public const int WM_TEST_STR = USER + 101;
  18. public const int WM_MSG = USER + 102;
  19. [System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
  20. public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
  21. /// <summary>
  22. /// 发送消息
  23. /// </summary>
  24. /// <param name="hWnd"></param>
  25. /// <param name="Msg"></param>
  26. /// <param name="wParam"></param>
  27. /// <param name="lParam"></param>
  28. /// <returns></returns>
  29. [DllImport("User32.dll", EntryPoint = "SendMessage")]
  30. private static extern int SendMessage(IntPtr hWnd,int Msg,int wParam,ref COPYDATASTRUCT lParam);
  31. /// <summary>
  32. /// 查找窗体
  33. /// </summary>
  34. /// <param name="lpClassName"></param>
  35. /// <param name="lpWindowName"></param>
  36. /// <returns></returns>
  37. [DllImport("User32.dll", EntryPoint = "FindWindow")]
  38. private static extern int FindWindow(string lpClassName, string lpWindowName);
  39. public struct COPYDATASTRUCT
  40. {
  41. public IntPtr dwData;
  42. public int cbData;
  43. [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
  44. public string lpData;
  45. }
  46. /// <summary>
  47. /// 移动窗体
  48. /// </summary>
  49. /// <param name="intPtr"></param>
  50. public static void FormMobile(IntPtr intPtr)
  51. {
  52. //释放鼠标焦点捕获
  53. Win32.ReleaseCapture();
  54. //向当前窗体发送拖动消息
  55. Win32.SendMessage(intPtr, 0x0112, 0xF011, 0);
  56. }
  57. /// <summary>
  58. /// Size大小
  59. /// </summary>
  60. [StructLayout(LayoutKind.Sequential)]
  61. public struct Size
  62. {
  63. public Int32 cx;
  64. public Int32 cy;
  65. public Size(Int32 x, Int32 y)
  66. {
  67. cx = x;
  68. cy = y;
  69. }
  70. }
  71. /// <summary>
  72. ///
  73. /// </summary>
  74. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  75. public struct BLENDFUNCTION
  76. {
  77. public byte BlendOp;
  78. public byte BlendFlags;
  79. public byte SourceConstantAlpha;
  80. public byte AlphaFormat;
  81. }
  82. [StructLayout(LayoutKind.Sequential)]
  83. public struct Point
  84. {
  85. public Int32 x;
  86. public Int32 y;
  87. public Point(Int32 x, Int32 y)
  88. {
  89. this.x = x;
  90. this.y = y;
  91. }
  92. }
  93. public const byte AC_SRC_OVER = 0;
  94. public const Int32 ULW_ALPHA = 2;
  95. public const byte AC_SRC_ALPHA = 1;
  96. /// <summary>
  97. /// 从左到右显示
  98. /// </summary>
  99. public const Int32 AW_HOR_POSITIVE = 0x00000001;
  100. /// <summary>
  101. /// 从右到左显示
  102. /// </summary>
  103. public const Int32 AW_HOR_NEGATIVE = 0x00000002;
  104. /// <summary>
  105. /// 从上到下显示
  106. /// </summary>
  107. public const Int32 AW_VER_POSITIVE = 0x00000004;
  108. /// <summary>
  109. /// 从下到上显示
  110. /// </summary>
  111. public const Int32 AW_VER_NEGATIVE = 0x00000008;
  112. /// <summary>
  113. /// 若使用了AW_HIDE标志,则使窗口向内重叠,即收缩窗口;否则使窗口向外扩展,即展开窗口
  114. /// </summary>
  115. public const Int32 AW_CENTER = 0x00000010;
  116. /// <summary>
  117. /// 隐藏窗口,缺省则显示窗口
  118. /// </summary>
  119. public const Int32 AW_HIDE = 0x00010000;
  120. /// <summary>
  121. /// 激活窗口。在使用了AW_HIDE标志后不能使用这个标志
  122. /// </summary>
  123. public const Int32 AW_ACTIVATE = 0x00020000;
  124. /// <summary>
  125. /// 使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略
  126. /// </summary>
  127. public const Int32 AW_SLIDE = 0x00040000;
  128. /// <summary>
  129. /// 透明度从高到低
  130. /// </summary>
  131. public const Int32 AW_BLEND = 0x00080000;
  132. /// <summary>
  133. /// 执行动画
  134. /// </summary>
  135. /// <param name="whnd">控件句柄</param>
  136. /// <param name="dwtime">动画时间</param>
  137. /// <param name="dwflag">动画组合名称</param>
  138. /// <returns>bool值,动画是否成功</returns>
  139. [DllImport("user32")]
  140. public static extern bool AnimateWindow(IntPtr whnd, int dwtime, int dwflag);
  141. /// <summary>
  142. ///
  143. /// </summary>
  144. /// <param name="sender"></param>
  145. /// <param name="e"></param>
  146. [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]//SendMessageTimeout是在user32.dll中定义的
  147. public static extern IntPtr SendMessageTimeout(IntPtr windowHandle,uint Msg,IntPtr wParam,IntPtr lParam,SendMessageTimeoutFlags flags, uint timeout,out IntPtr result);
  148. [Flags]
  149. public enum SendMessageTimeoutFlags : uint
  150. {
  151. SMTO_NORMAL = 0x0000,
  152. SMTO_BLOCK = 0x0001,
  153. SMTO_ABORTIFHUNG = 0x0002,
  154. SMTO_NOTIMEOUTIFNOTHUNG = 0x0008
  155. }
  156. /// <summary>
  157. /// <para>该函数将指定的消息发送到一个或多个窗口。</para>
  158. /// <para>此函数为指定的窗口调用窗口程序直到窗口程序处理完消息再返回。</para>
  159. /// <para>而函数PostMessage不同,将一个消息寄送到一个线程的消息队列后立即返回。</para>
  160. /// return 返回值 : 指定消息处理的结果,依赖于所发送的消息。
  161. /// </summary>
  162. /// <param name="hWnd">要接收消息的那个窗口的句柄</param>
  163. /// <param name="Msg">消息的标识符</param>
  164. /// <param name="wParam">具体取决于消息</param>
  165. /// <param name="lParam">具体取决于消息</param>
  166. [DllImport("User32.dll", CharSet = CharSet.Auto, EntryPoint = "SendMessageA")]
  167. public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
  168. [DllImport("user32.dll")]
  169. public static extern bool ReleaseCapture();
  170. [DllImport("user32")]
  171. public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
  172. [DllImport("gdi32.dll")]
  173. public static extern int CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3);
  174. [DllImport("user32.dll")]
  175. public static extern int SetWindowRgn(IntPtr hwnd, int hRgn, Boolean bRedraw);
  176. [DllImport("user32", EntryPoint = "GetWindowLong")]
  177. public static extern int GetWindowLong(
  178. IntPtr hwnd, int nIndex);
  179. [DllImport("user32.dll")]
  180. public static extern int SetWindowLong(
  181. IntPtr hwnd, int nIndex, int dwNewLong);
  182. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  183. public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
  184. [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
  185. public static extern IntPtr GetDC(IntPtr hWnd);
  186. [DllImport("gdi32.dll", ExactSpelling = true)]
  187. public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObj);
  188. [DllImport("user32.dll", ExactSpelling = true)]
  189. public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
  190. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  191. public static extern int DeleteDC(IntPtr hDC);
  192. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  193. public static extern int DeleteObject(IntPtr hObj);
  194. [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
  195. public static extern int UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pptSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);
  196. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  197. public static extern IntPtr ExtCreateRegion(IntPtr lpXform, uint nCount, IntPtr rgnData);
  198. [DllImport("user32.dll")]
  199. public static extern int ExitWindowsEx(int x, int y);
  200. #region USB设备插入或拨出监控
  201. public const int WM_DEVICECHANGE = 0x0219;
  202. public const int DBT_DEVICEARRIVAL = 0x8000, // systemdetected a new device
  203. DBT_DEVICEREMOVECOMPLETE = 0x8004; // device is gone
  204. public const int DEVICE_NOTIFY_WINDOW_HANDLE = 0,
  205. DEVICE_NOTIFY_SERVICE_HANDLE = 1;
  206. public const int DBT_DEVTYP_DEVICEINTERFACE = 0x00000005; // deviceinterface class
  207. public static Guid GUID_DEVINTERFACE_USB_DEVICE = new Guid("A5DCBF10-6530-11D2-901F-00C04FB951ED");
  208. [StructLayout(LayoutKind.Sequential)]
  209. public class DEV_BROADCAST_HDR
  210. {
  211. public int dbcc_size;
  212. public int dbcc_devicetype;
  213. public int dbcc_reserved;
  214. }
  215. [StructLayout(LayoutKind.Sequential)]
  216. public class DEV_BROADCAST_DEVICEINTERFACE
  217. {
  218. public int dbcc_size;
  219. public int dbcc_devicetype;
  220. public int dbcc_reserved;
  221. public Guid dbcc_classguid;
  222. public short dbcc_name;
  223. }
  224. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
  225. public class DEV_BROADCAST_DEVICEINTERFACE1
  226. {
  227. public int dbcc_size;
  228. public int dbcc_devicetype;
  229. public int dbcc_reserved;
  230. [MarshalAs(UnmanagedType.ByValArray, ArraySubType=UnmanagedType.U1, SizeConst=16)]
  231. public byte [] dbcc_classguid;
  232. [MarshalAs(UnmanagedType.ByValArray, SizeConst=128)]
  233. public char [] dbcc_name;
  234. }
  235. [DllImport("user32.dll", SetLastError=true)]
  236. public static extern IntPtr RegisterDeviceNotification( IntPtr hRecipient, IntPtr NotificationFilter, Int32 Flags);
  237. [DllImport("kernel32.dll")]
  238. public static extern int GetLastError();
  239. /// <summary>
  240. /// 注册设备通知
  241. /// </summary>
  242. /// <param name="Handle"></param>
  243. public static void RegisterDeviceNotification(IntPtr Handle)
  244. {
  245. Win32.DEV_BROADCAST_DEVICEINTERFACE dbi = new
  246. Win32.DEV_BROADCAST_DEVICEINTERFACE();
  247. int size = Marshal.SizeOf(dbi);
  248. dbi.dbcc_size = size;
  249. dbi.dbcc_devicetype = Win32.DBT_DEVTYP_DEVICEINTERFACE;
  250. dbi.dbcc_reserved = 0;
  251. dbi.dbcc_classguid = Win32.GUID_DEVINTERFACE_USB_DEVICE;
  252. dbi.dbcc_name = 0;
  253. IntPtr buffer = Marshal.AllocHGlobal(size);
  254. Marshal.StructureToPtr(dbi, buffer, true);
  255. IntPtr r = Win32.RegisterDeviceNotification(Handle, buffer,
  256. Win32.DEVICE_NOTIFY_WINDOW_HANDLE);
  257. if (r == IntPtr.Zero)
  258. System.Windows.Forms.MessageBox.Show(Win32.GetLastError().ToString());
  259. }
  260. #endregion
  261. #region 获取文件图标
  262. public const uint SHGFI_ICON = 0x100;
  263. public const uint SHGFI_LARGEICON = 0x0; // Large icon
  264. public const uint SHGFI_SMALLICON = 0x1; // Small icon
  265. /// <summary>
  266. /// 获取一个图标
  267. /// </summary>
  268. /// <param name="pszPath"></param>
  269. /// <param name="dwFileAttributes"></param>
  270. /// <param name="psfi"></param>
  271. /// <param name="cbSizeFileInfo"></param>
  272. /// <param name="uFlags"></param>
  273. /// <returns></returns>
  274. [System.Runtime.InteropServices.DllImport("shell32.dll")]
  275. public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);
  276. /// <summary>
  277. /// 销毁一个图标并且释放该图标所占用的内存;
  278. /// </summary>
  279. /// <param name="handle"></param>
  280. /// <returns></returns>
  281. [System.Runtime.InteropServices.DllImport("user32.dll")]
  282. public static extern bool DestroyIcon(IntPtr handle);
  283. /// <summary>
  284. /// 获取文件图标的Image
  285. /// </summary>
  286. /// <param name="fileFullPath"></param>
  287. /// <returns></returns>
  288. public static System.Drawing.Image GetFileImage(string fileFullPath)
  289. {
  290. System.Drawing.Image fileIconImage = null;
  291. System.Drawing.IconConverter imageConverter = new System.Drawing.IconConverter();
  292. System.Drawing.Icon icon = GetFileIcon(fileFullPath);
  293. try
  294. {
  295. if (icon != null)
  296. {
  297. fileIconImage = (System.Drawing.Image)
  298. imageConverter.ConvertTo(icon, typeof(System.Drawing.Image));
  299. }
  300. }
  301. catch (NotSupportedException)
  302. {
  303. }
  304. return fileIconImage;
  305. }
  306. /// <summary>
  307. /// 获取文件图标的Icon
  308. /// </summary>
  309. /// <param name="fileFullPath"></param>
  310. /// <returns></returns>
  311. public static System.Drawing.Icon GetFileIcon(string fileFullPath)
  312. {
  313. string filePath = fileFullPath;
  314. if (System.IO.File.Exists(filePath))
  315. {
  316. System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);
  317. //
  318. // Get the File icon
  319. //
  320. SHFILEINFO shinfo = new SHFILEINFO();
  321. IntPtr hImg = Win32.SHGetFileInfo(filePath, 0, ref shinfo,
  322. (uint)System.Runtime.InteropServices.Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON);
  323. if (shinfo.hIcon != null)
  324. {
  325. //The icon is returned in the hIcon member of the shinfo struct
  326. System.Drawing.IconConverter imageConverter = new System.Drawing.IconConverter();
  327. System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(shinfo.hIcon);
  328. Win32.DestroyIcon(shinfo.hIcon);
  329. return icon;
  330. }
  331. else
  332. {
  333. return null;
  334. }
  335. }
  336. else { return null; }
  337. }
  338. #endregion
  339. /// <summary>
  340. /// 获取指定驱动容量大小
  341. /// </summary>
  342. /// <param name="drive">指定驱动路径</param>
  343. /// <param name="freeBytes">可用大小字节</param>
  344. /// <param name="totalBytes">总共容量大小字节</param>
  345. /// <param name="totalFreeBytes">总共可用大小字节</param>
  346. /// <returns></returns>
  347. [DllImport("KERNEL32.DLL ", EntryPoint = "GetDiskFreeSpaceExW", CharSet = CharSet.Unicode,SetLastError = true)]
  348. public static extern bool GetDiskFreeSpace(string drive, ref long freeBytes, ref long totalBytes, ref long totalFreeBytes);
  349. [System.Runtime.InteropServices.DllImport("Kernel32.dll")]
  350. public extern static int FormatMessage(int flag, ref IntPtr source, int msgid, int langid, ref string buf, int size, ref IntPtr args);
  351. /// <summary>
  352. /// 获取系统错误信息描述
  353. /// </summary>
  354. /// <param name="errCode">系统错误码</param>
  355. /// <returns></returns>
  356. public static string GetSysErrMsg(int errCode)
  357. {
  358. IntPtr tempptr = IntPtr.Zero;
  359. string msg = null;
  360. FormatMessage(0x1300, ref tempptr, errCode, 0, ref msg, 255, ref tempptr);
  361. return msg;
  362. }
  363. }
  364. [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
  365. public struct SHFILEINFO
  366. {
  367. public IntPtr hIcon;
  368. public IntPtr iIcon;
  369. public uint dwAttributes;
  370. [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 260)]
  371. public string szDisplayName;
  372. [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 80)]
  373. public string szTypeName;
  374. }
  375. /// <summary>
  376. ///
  377. /// </summary>
  378. public struct MyDriverInfo
  379. {
  380. private string errorMessages;
  381. /// <summary>
  382. /// 错误信息
  383. /// </summary>
  384. public string ErrorMessages
  385. {
  386. get { return errorMessages; }
  387. set { errorMessages = value; }
  388. }
  389. private string driverPath;
  390. /// <summary>
  391. /// 指定驱动路径
  392. /// </summary>
  393. public string DriverPath
  394. {
  395. get { return driverPath; }
  396. set { driverPath = value; }
  397. }
  398. private long freeBytes;//可用大小
  399. /// <summary>
  400. /// 可用大小字节
  401. /// </summary>
  402. public long FreeBytes
  403. {
  404. get { return freeBytes; }
  405. set { freeBytes = value; }
  406. }
  407. private long totalBytes;//
  408. /// <summary>
  409. /// 总共容量大小字节
  410. /// </summary>
  411. public long TotalBytes
  412. {
  413. get { return totalBytes; }
  414. set { totalBytes = value; }
  415. }
  416. private long totalFreeBytes;
  417. /// <summary>
  418. /// 总共可用大小字节
  419. /// </summary>
  420. public long TotalFreeBytes
  421. {
  422. get { return totalFreeBytes; }
  423. set { totalFreeBytes = value; }
  424. }
  425. /// <summary>
  426. /// 可用大小 GB
  427. /// </summary>
  428. public int G_FreeBytes
  429. {
  430. get
  431. {
  432. if (freeBytes > 0)
  433. {
  434. return Convert.ToInt32(freeBytes / 1024 / 1024 / 1024);
  435. }
  436. else
  437. {
  438. return 0;
  439. }
  440. }
  441. }
  442. /// <summary>
  443. /// 总共容量大小 GB
  444. /// </summary>
  445. public int G_TotalBytes
  446. {
  447. get
  448. {
  449. if (totalBytes > 0)
  450. {
  451. return Convert.ToInt32(totalBytes / 1024 / 1024 / 1024);
  452. }
  453. else
  454. {
  455. return 0;
  456. }
  457. }
  458. }
  459. /// <summary>
  460. /// 总共可用大小 GB
  461. /// </summary>
  462. public int G_TotalFreeBytes
  463. {
  464. get
  465. {
  466. if (totalFreeBytes > 0)
  467. {
  468. return Convert.ToInt32(totalFreeBytes / 1024 / 1024 / 1024);
  469. }
  470. else
  471. {
  472. return 0;
  473. }
  474. }
  475. }
  476. //////////
  477. /// <summary>
  478. /// 可用大小 GB
  479. /// </summary>
  480. public double GDouble_FreeBytes
  481. {
  482. get
  483. {
  484. if (freeBytes > 0)
  485. {
  486. return Convert.ToDouble(freeBytes / 1024.0 / 1024.0 / 1024.0);
  487. }
  488. else
  489. {
  490. return 0;
  491. }
  492. }
  493. }
  494. /// <summary>
  495. /// 总共容量大小 GB
  496. /// </summary>
  497. public double GDouble_TotalBytes
  498. {
  499. get
  500. {
  501. if (totalBytes > 0)
  502. {
  503. return Convert.ToDouble(totalBytes / 1024.0 / 1024.0 / 1024.0);
  504. }
  505. else
  506. {
  507. return 0;
  508. }
  509. }
  510. }
  511. /// <summary>
  512. /// 总共可用大小 GB
  513. /// </summary>
  514. public double GDouble_TotalFreeBytes
  515. {
  516. get
  517. {
  518. if (totalFreeBytes > 0)
  519. {
  520. return Convert.ToDouble(totalFreeBytes / 1024.0 / 1024.0 / 1024.0);
  521. }
  522. else
  523. {
  524. return 0;
  525. }
  526. }
  527. }
  528. }
  529. public class Win_X86
  530. {
  531. /// <summary>
  532. /// C++ Dll 生成缩略图
  533. /// </summary>
  534. /// <param name="lpImgPath">要生成的原图路径</param>
  535. /// <param name="lpNewImgPath">生成的缩略图要保存的路径</param>
  536. /// <param name="dwWidth">缩略图宽</param>
  537. /// <param name="dwHeight">缩略图高</param>
  538. /// <param name="dwQuality">0~100 品质 如果为 0 时无法控件品质 但可以使32位系统生成百兆以后相片的缩略图</param>
  539. /// <returns></returns>
  540. [System.Runtime.InteropServices.DllImport("SimpleImgThumbnail_x86")]
  541. public static extern bool GenerationThumbnail(string lpImgPath, string lpNewImgPath, uint dwWidth, uint dwHeight, uint dwQuality);
  542. /// <summary>
  543. /// C++ Dll 获取指定图片信息
  544. /// </summary>
  545. /// <param name="lpImgPath">要获取的指定的图片信息</param>
  546. /// <param name="dwWidth">ref 宽</param>
  547. /// <param name="dwHeight">ref 高</param>
  548. /// <param name="fHorizontal">ref 水平方向分辨率</param>
  549. /// <param name="fVertical">ref 垂直方向分辨率</param>
  550. /// <returns></returns>
  551. [System.Runtime.InteropServices.DllImport("SimpleImgThumbnail_x86")]
  552. public static extern bool GetImgInfo(string lpImgPath, ref uint dwWidth, ref uint dwHeight, ref float fHorizontal, ref float fVertical);
  553. }
  554. public class Win_X64
  555. {
  556. /// <summary>
  557. /// C++ Dll 生成缩略图
  558. /// </summary>
  559. /// <param name="lpImgPath">要生成的原图路径</param>
  560. /// <param name="lpNewImgPath">生成的缩略图要保存的路径</param>
  561. /// <param name="dwWidth">缩略图宽</param>
  562. /// <param name="dwHeight">缩略图高</param>
  563. /// <param name="dwQuality">0~100 品质 如果为 0 时无法控件品质 但可以使32位系统生成百兆以后相片的缩略图</param>
  564. /// <returns></returns>
  565. [System.Runtime.InteropServices.DllImport("SimpleImgThumbnail_x64")]
  566. public static extern bool GenerationThumbnail(string lpImgPath, string lpNewImgPath, uint dwWidth, uint dwHeight, uint dwQuality);
  567. /// <summary>
  568. /// C++ Dll 获取指定图片信息
  569. /// </summary>
  570. /// <param name="lpImgPath">要获取的指定的图片信息</param>
  571. /// <param name="dwWidth">ref 宽</param>
  572. /// <param name="dwHeight">ref 高</param>
  573. /// <param name="fHorizontal">ref 水平方向分辨率</param>
  574. /// <param name="fVertical">ref 垂直方向分辨率</param>
  575. /// <returns></returns>
  576. [System.Runtime.InteropServices.DllImport("SimpleImgThumbnail_x64")]
  577. public static extern bool GetImgInfo(string lpImgPath, ref uint dwWidth, ref uint dwHeight, ref float fHorizontal, ref float fVertical);
  578. }
  579. public class VCMD5_X86
  580. {
  581. [System.Runtime.InteropServices.DllImport("lyfzMD5_x86.dll")]
  582. public static extern int GetStringMD5(string lpString, IntPtr pResult, int length);
  583. [System.Runtime.InteropServices.DllImport("lyfzMD5_x86.dll")]
  584. public static extern int GetFileMD5(string lpFilepath, IntPtr pResult, int length);
  585. [System.Runtime.InteropServices.DllImport("lyfzMD5_x86.dll")]
  586. public static extern int GetByteMD5(IntPtr lpBytes, int nInputlen, IntPtr pResult);
  587. }
  588. public class VCMD5_X64
  589. {
  590. [System.Runtime.InteropServices.DllImport("lyfzMD5_x64.dll")]
  591. public static extern int GetStringMD5(string lpString, IntPtr pResult, int length);
  592. [System.Runtime.InteropServices.DllImport("lyfzMD5_x64.dll")]
  593. public static extern int GetFileMD5(string lpFilepath, IntPtr pResult, int length);
  594. [System.Runtime.InteropServices.DllImport("lyfzMD5_x64.dll")]
  595. public static extern int GetByteMD5(IntPtr lpBytes, int nInputlen, IntPtr pResult);
  596. }
  597. }