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 6143791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:33:58+00:00 2026-05-23T18:33:58+00:00

I’ve been trying to build an application in C++ using WinSNMP, and although I’m

  • 0

I’ve been trying to build an application in C++ using WinSNMP, and although I’m slowly making progress, I keep running into issues. So far, my program tries to startup, create, and open an SNMP session, sets a port, and then attempts to listen to that port, then exits. I have it printing out the values of all the variables its accessing, so I can track everything in the program. The values I’m getting now make no sense at all, some of them are repeated for different variables that have no relation, and some stay null or at 0 even though they are given values & aren’t changed. I’m stuck & don’t know what to do about this, or what to do next to build the program. My code is as follows:

#include <WinSnmp.h>
#include <stdio.h>
#define MY_BUFSIZE 1024 // Buffer size for console window titles.

smiUINT32  majorVers;
smiUINT32  minorVers;
smiUINT32  nLevel;
smiUINT32  translateMode;
smiUINT32  retranslateMode;

UINT       msgNum=1;
UINT       port = 80;

HWND       window;

char oldWindowTitle[MY_BUFSIZE];

HSNMP_ENTITY      entity;
SNMPAPI_STATUS    status;
SNMPAPI_CALLBACK  callBackNum;


void Startup(){

    //Starting the snmp session
    SnmpStartup(&majorVers, &minorVers, &nLevel, &translateMode, &retranslateMode);

    printf( "Major Version:    %i \n"
            "Minor Version:    %i \n"
            "nLevel:           %i \n"
            "Translate Mode:   %i \n"
            "Retranslate Mode: %i \n\n", 
            (majorVers, minorVers, nLevel, translateMode, retranslateMode));

    GetConsoleTitle((LPWSTR)oldWindowTitle, MY_BUFSIZE);
    window = FindWindow(NULL, (LPCWSTR)oldWindowTitle);

}

void CreateSession(){

    SnmpCreateSession(window,msgNum,callBackNum,NULL);
    printf("Create session returns: %i \n\n", SnmpCreateSession(window,msgNum,callBackNum,NULL));
    printf( "Window:        %i\n"
            "msg num:       %i\n"
            "Call Back num: %i\n\n",
            (window,msgNum,callBackNum));
}

void OpenSession(){
    SnmpOpen(window, msgNum);
    printf("Open session returns: %i\n\n", SnmpOpen(window, msgNum));

}

void SetPort(){
    SnmpSetPort(entity,port);
    printf( "Entity: %i\n"
            "Port:   %i\n\n",
            (entity,port));
}

void Listen(){
    SnmpListen(entity,status);
    printf( "Entity: %i\n"
            "Status: %i\n\n",
            (entity,status));
}
int main(){

    Startup();
    CreateSession();
    OpenSession();
    SetPort();
    Listen();
    SnmpCleanup();

}

The values it is returning are as follows:

        Major Version:    1
        Minor Version:    4320440
        nLevel:           4320760
        Translate Mode:   4320628
        Retranslate Mode: 1358752

        Create Session returns:  2

        Window:        0
        msg num:       4320436
        Call Back num: 4320760

        Open Session returns:  4

        Entity:   80
        Port:     4320444

        Entity:   0
        Status:   4320444

Im lost here. any advice/help?

note that the returned values are generally different/random every time, aside from the single & double digit numbers which are constant.

  • 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-23T18:33:59+00:00Added an answer on May 23, 2026 at 6:33 pm

    You only pass two arguments to printf: one format string and retranslateMode. Get rid of the parenthesis around your variables in the call and it should work as you expect.

    Background: The expression (a, b) evaluates a, discards the result, and then yields b. One place where applying this comma operator is useful is code like ++i, ++j in for loops.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build
I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.