您当前的位置: 首页 > 

phymat.nico

暂无认证

  • 2浏览

    0关注

    1967博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

win10+vs2017 snmp开发实例

phymat.nico 发布时间:2020-04-06 16:46:08 ,浏览量:2

// TestSnmp.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include 
#include 
#include 
#include 
#pragma comment(lib,"snmpapi.lib")
#pragma comment(lib,"mgmtapi.lib")

#define MAXNUMIP    10000
#define MAXNUMLIST  200
#define GET			0
#define GETNEXT		1
#define SET			2
#define WALK		3
#define INIFILENAME ".\\SNMPTools.ini"


#define SYSDESCR      "1.3.6.1.2.1.1.1.0"        //ObjectID for system descriptor   
#define SYSOBJECTID   "1.3.6.1.2.1.1.2.0"        //ObjectID for system object ID   
#define SYSCONTACT    "1.3.6.1.2.1.1.4.0"        //ObjectID for system contact   

#pragma comment(lib, "ws2_32.lib")  

int main(int argc, char *argv[])
{
    std::cout  0)
		{
			printf("Error: errorStatus=%d, errorIndex=%d\n", errorStatus, errorIndex);
			break;
		}
		else
		{
			// Display the resulting variable bindings.
			UINT i;
			char *string = NULL;
			for (i = 0; i < variableBindings.len; i++)
			{
				SnmpMgrOidToStr(&variableBindings.list[i].name, &string);
				//printf("Variable = %s\n", string);
				printf("%l100s\t", string);
				if (string) SNMP_free(string);
				//printf("Value = ");
				SnmpUtilPrintAsnAny(&variableBindings.list[i].value);

				printf("\n");
			} // end for()
		} // end else
		i++;
		if (i == 1000)
			break;
	} // end while

	SnmpUtilVarBindListFree(&variableBindings);

	if (!SnmpMgrClose(session))
	{
		printf("error on SnmpMgrClose %d\n", GetLastError());
		return 1;
	}

	getchar();
	return 0;
}

 

关注
打赏
1659628745
查看更多评论
立即登录/注册

微信扫码登录

0.0465s