⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 safenativemethods.cs

📁 SerialPort 串口通讯用
💻 CS
字号:
// ==++==
// 
//   Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// ==--==
/*============================================================
**
** Class:  System.IO.Ports.SafeNativeMethods

** Purpose: Wrapper for all SerialPort/SerialStream-related PInvoke methods
**		  : and hub for all constant definitions considered to be safe to the OS.
**
** Date:  August 2002
**
===========================================================*/


using System;
using System.Configuration.Assemblies;
using System.Runtime.Remoting;
using System.IO;
using System.Text;
using System.ComponentModel;
using System.Resources;
using System.Runtime;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Threading;

namespace System.IO.Ports
{
	internal sealed class SafeNativeMethods
	{

		[DllImport(NativeMethods.KERNEL32, CharSet=CharSet.Auto)]
		internal static extern int FormatMessage(int dwFlags, IntPtr lpSource,
			int dwMessageId, int dwLanguageId, StringBuilder lpBuffer,
			int nSize, IntPtr va_list_arguments);
		
		// Use this to translate error codes like the above into HRESULTs like
		// 0x80070006 for ERROR_INVALID_HANDLE
		internal static int MakeHRFromErrorCode(int errorCode)
		{
			
			return unchecked(((int)0x80070000) | errorCode);
		}

		[DllImport(NativeMethods.KERNEL32, SetLastError=true, CharSet=CharSet.Auto)]
		internal static extern int GetLastError();
	
		[DllImport(NativeMethods.KERNEL32, SetLastError=true, CharSet=CharSet.Auto)]
		internal static extern int GetTickCount();
		
	
	}

	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -