SNMP C++ Example
SNMPGet
->
SNMPGetNext
SNMPGetBulk
SNMPSet
Download
Full Trial (998KB)
eMarkSnmpTrial.zip
ActiveX/Component Library
Active Server Flash
Active Server Image
eMarkSNMP Get C++ Sample
C++ SNMP Gext
// #include "stdafx.h" #include
#import "..\..\Output\eMarkSnmp.tlb" using namespace eMarkSnmpLib; int _tmain(int argc, _TCHAR* argv[]) { CoInitialize(NULL); ISnmpSessionPtr pSession("eMarkSnmp.SnmpSession.1"); try { pSession->Open(); pSession->SnmpParam->CommunityGet = "public"; pSession->SnmpParam->Timeout = 1000; pSession->SnmpParam->Retries = 1; int i = pSession->SnmpGet("127.0.0.1", "1.3.6.1.2.1.1.2.0"); std::cout << "Got varbinds: " << i << std::endl; if (i>0) { std::cout << "Snmp VarBinding: " << std::endl; IVarBindCollectionPtr pVBColl = pSession->VarBinds; std::cout << "Oid: " << pVBColl->Item[1]->ObjectID <
Item[1]->ToString().length() > 0) std::cout << "StringValue: " << pVBColl->Item[1]->ToString() << std::endl; if (pVBColl->Item[1]->ToHexString().length() > 0) std::cout << "HexValue: " << pVBColl->Item[1]->ToHexString() << std::endl; } std::cout << "Done." << std::endl; } catch (const _com_error& Err) { std::cout << "Error: \n"; std::cout << "Description: " << Err.Description() << "\n"; std::cout << "Source: " << Err.Source() << "\n"; } catch (...) { std::cout << "Unexpected Error\n"; } pSession->Close(); pSession = NULL; CoUninitialize(); return 0; }