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

📄 functions.cs

📁 E:工具软件Thomas0108.zip
💻 CS
字号:
using System;
using System.Runtime.InteropServices;

namespace WinSnmp
{
	/// <summary>
	/// Snmp API Functions
	/// </summary>
	public class SnmpAPI
	{
		// Callback
		public delegate SNMPAPI_STATUS SnmpCallback(IntPtr session, IntPtr hwnd, int msg, uint wparam, uint lparam, IntPtr data);

		// Communication functions
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpStartup(out int major, out int minor, out int level, out int translate, out int retransmit);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpCleanup();
		[DllImport("wsnmp32.dll")]
		public static extern IntPtr SnmpCreateSession(IntPtr hwnd, int msg, SnmpCallback callback, IntPtr data);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpClose(IntPtr session);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpRegister(IntPtr session, IntPtr src, IntPtr dest, IntPtr context, IntPtr notification, int state);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpListen(IntPtr entity, IntPtr status);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpSendMsg(IntPtr session, IntPtr src, IntPtr dest, IntPtr context, IntPtr pdu);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpRecvMsg(IntPtr session, out IntPtr src, out IntPtr dest, out IntPtr context, out IntPtr pdu);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpCancelMsg(IntPtr session, IntPtr reqid);

		// Entity and Context functions
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpContextToStr(IntPtr context, ref SMIOCTETS octets);
		[DllImport("wsnmp32.dll")]
		public static extern IntPtr SnmpStrToContext(IntPtr session, ref SMIOCTETS octets);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpFreeEntity(IntPtr entity);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpEntityToStr(IntPtr entity, int size, IntPtr str);
		[DllImport("wsnmp32.dll")]
		public static extern IntPtr SnmpStrToEntity(IntPtr session, [MarshalAs(UnmanagedType.LPStr)] string str);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpFreeContext(IntPtr context);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpSetPort(IntPtr entity, int port);

		// Database functions
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpGetRetransmitMode(out uint mode);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpGetRetry(IntPtr entity, out uint policy, out uint actual);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpGetTimeout(IntPtr entity, out int policy, out int actual);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpGetTranslateMode(out uint mode);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpGetVendorInfo(ref VENDORINFO Info);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpSetRetransmitMode(SNMPAPI_RETRANSMIT mode);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpSetRetry(IntPtr entity, int policy);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpSetTimeout(IntPtr entity, int policy);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpSetTranslateMode(SNMPAPI_TRANSLATE mode);

		// PDU functions
		[DllImport("wsnmp32.dll")]
		public static extern IntPtr SnmpCreatePdu(IntPtr session, int type, int reqid, int status, int index, IntPtr vblist);
		[DllImport("wsnmp32.dll")]
		public static extern IntPtr SnmpDuplicatePdu(IntPtr session, IntPtr pdu);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpFreePdu(IntPtr pdu);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpGetPduData(IntPtr pdu, out int type, out int reqid, out int status, out int index, out IntPtr vblist);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpSetPduData(IntPtr pdu, ref int type, ref int reqid, ref int nonrepeaters, ref int maxreps, ref IntPtr vblist);

		// Utility functions
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpDecodeMsg(IntPtr session, out IntPtr src, out IntPtr dest, out IntPtr context, out IntPtr pdu, ref SMIOCTETS octets);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpEncodeMsg(IntPtr session, IntPtr src, IntPtr dest, IntPtr context, IntPtr pdu, ref SMIOCTETS octets);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpFreeDescriptor(int syntax, ref SMIOID desc);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpFreeDescriptor(int syntax, ref SMIOCTETS desc);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpGetLastError(IntPtr session);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpOidCompare(IntPtr oid1, IntPtr oid2, int max, ref int result);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpOidCopy(IntPtr src, IntPtr dest);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpOidToStr(ref SMIOID oid, int size, IntPtr str);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpStrToOid(string str, ref SMIOID oid);

		// Variable Binding functions
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpCountVbl(IntPtr vbl);
		[DllImport("wsnmp32.dll")]
		public static extern IntPtr SnmpCreateVbl(IntPtr session, ref SMIOID name, ref SMIVALUE value);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpDeleteVb(IntPtr vbl, int index);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpDuplicateVbl(IntPtr session, IntPtr vbl);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpFreeVbl(IntPtr vbl);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpGetVb(IntPtr vbl, int index, ref SMIOID name, ref SMIVALUE value);
		[DllImport("wsnmp32.dll")]
		public static extern SNMPAPI_STATUS SnmpSetVb(IntPtr vbl, int index, ref SMIOID name, ref SMIVALUE value);
	}
}

⌨️ 快捷键说明

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