Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6890089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:14:16+00:00 2026-05-27T06:14:16+00:00

I just started with WinSNMP (in Visual Studio 2005), and have written the following

  • 0

I just started with WinSNMP (in Visual Studio 2005), and have written the following code. (This is a snippet.)

m_Status = SnmpStartup(&m_MajorVersion, &m_MinorVersion, &m_Level, &m_TranslateMode, &m_RetransmissionMode);
ASSERT(m_Status != SNMPAPI_FAILURE);

m_SnmpSession = SnmpCreateSession(GetSafeHwnd(), WM_SNMP_TEST, &CallBackFunction, NULL);
ASSERT(m_SnmpSession != SNMPAPI_FAILURE);

SnmpStrToOid("1.3.6.1.2.1.1.3.0", m_pIOD);

m_Status = SnmpRegister(&m_SnmpSession, m_pSrcEntity, m_pDstEntity, m_pContext, m_pIOD, SNMPAPI_ON);

SNMPAPI_STATUS temp = SnmpGetLastError(m_SnmpSession);
ASSERT(m_Status != SNMPAPI_FAILURE);

CallBackFunction is defined as:

SNMPAPI_STATUS CALLBACK CallBackFunction
(HSNMP_SESSION hSession=0, HWND hWnd=0, UINT wMsg=0,
 WPARAM wParam=0, LPARAM lParam=0, LPVOID lpClientData=0)
{
    return (SNMPAPI_SUCCESS);
}

m_pSrcEntity, m_pDstEntity, m_pContext are NULL in the example.
WM_SNMP_TEST has been registed by me as a Windows Message.

The first ASSERT succeeds. m_SnmpSession gets the value 0x00000001 when the SnmpCreateSession() is called, so second ASSERT also succeeds. Is that normal? I mean can the session have the mentioned value? Then the SnmpRegister() fails and SnmpGetLastError() returns 1. My Windows SNMP and SNMP Trap services are running. What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:14:16+00:00Added an answer on May 27, 2026 at 6:14 am

    The issue was that I was passing LPHSNMP_ENTITY, LPHSNMP_CONTECXT, LPHSNMP_SESSION, etc to functions where HSNMP_ENTITY, HSNMP_CONTECXT, HSNMP_SESSION, etc were required. Visual Studio was not detecting these errors even at run-time as these all are basically HANDLEs.

    But I still wonder whether the value of m_SnmpSession can be 0x1 or not. Infact, any Source/Destination entity that I created is always equivalent to 0x1. I am confused because they are all HANDLEs, and can 2 handles be the same? Any ideas?

    EDIT: It worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python
Just started learning Haskell. I have an empty source file with this inside: pe
Just started using Visual Studio 2008 and was hoping to convert my VBA UserForms
Just started exploring Cocoa so pretty much a total noob. I've written a very
Just started looking into encryption using keys and certificates in sql server 2005/08 and
Just started using Blueprint CSS and now playing with the grids but have a
Just started working with android and ran into a small problem. I am have
Just started a site and I have an /img directory on the main domain.
Just started a site and I have an /img directory on the main domain.
Just started with JavaCC. But I have a strange behaviour with it. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.