Problem with SNMP API call in VB - please help! 
Author Message
 Problem with SNMP API call in VB - please help!

I am working on a VB module that uses the SNMP API.
I am having problems now in translating the C declaration of an SNMP API
function.

The original C code:
--------------------

#define  RECVBUFSIZE    4096

//Type definitions

typedef SOCKET SockDesc;        // Socket is u_int in winsock.h, thats
long in VB

typedef struct _SNMP_MGR_SESSION {
    SockDesc  fd;
    struct  sockaddr  destAddr;            // sockaddr is from winsock.h

    LPSTR community;
    INT  timeout;
    INT  retries;
    AsnInteger  requestId;                    // is defined as LONG in C

    char  recvBuf[RECVBUFSIZE];

Quote:
}  SNMP_MGR_SESSION, *LPSNMP_MGR_SESSION;

// function prototype

LPSNMP_MGR_SESSION
SNMP_FUNC_TYPE
SnmpMgrOpen(
    IN  LPSTR  lpAgentAddress,
    IN  LPSTR  lpAgentCommunity,
    IN  INT  nTimeOut,
    IN  INT  nRetries
    );

In a C sample program from the Platform SDK, the function is called like
this:

LPSNMP_MGR_SESSION  session;

session = SnmpMgrOpen(agent, community, timeout, retries)

That is my translation in VB:
----------------------------

Type sockaddr                    ' Taken from winsock.h
  sa_family As Integer          '/* address family */
  sa_data(14) As Byte           '/* up to 14 bytes of direct address */
End Type

Public Type Type_SNMP_MGR_SESSION
    fd As Long                                    ' Socket descriptor,
u_int in C
    destAddr As sockaddr
    community As String
    timeout As Long
    retries As Long
    requestId As Long
    recvBuf As String * 4096
End Type

'*************************************************
'**SNMP API Management Funktionen (MGMTAPI.DLL) **
'*************************************************
Declare Function SnmpMgrOpen Lib "mgmtapi.dll" _
                                 (ByVal lpAgentAddress As String, _
                                  ByVal lpAgentCommunity As String, _
                                  ByVal nTimeout As Long, _
                                  ByVal nRetries As Long) As
Type_SNMP_MGR_SESSION

My function call in VB:
-----------------------

Dim session As Type_SNMP_MGR_SESSION
Dim agent as String
Dim community as String
Dim timeout as Long
Dim retries as Long

session = SnmpMgrOpen(agent, community, timeout, retries)

This function call fails (wrong calling conventions). What is wrong with
my declaration?

Please help! I need it very urgently!

Andre

---------------------------
Andre Schneickert
ESCS, Germany



Mon, 17 Jul 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Problem with SNMP API call in VB - please help!

2. Problem with SNMP API call in VB - please help!

3. Calling the SNMP API

4. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

5. Problems getting snmp tables from orinoco/kbridge radios using Dart powertcp snmp control

6. Problems getting snmp tables from orinoco/kbridge radios using Dart powertcp snmp control

7. Windows API call to set windows colors (HELP Please)

8. Help with RegEnumValue API call please

9. Help please accessing registry with API calls

10. Help me with API call please.

11. AbortPrinter API call and hPrinter help please...

12. Need help with Vb5 API call, PLEASE!

 

 
Powered by phpBB® Forum Software