473,441 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

Problem using API function GetExtendedTcpTable

Hi All I am trying to use the function GetExtendedTcpTable, I looked on the
MSDN found the C++ definition and tried to convert it but it does not seem
to be working, it returns 87 which is = ERROR_INVALID_PARAMETER

I have checked the parameters it looks correct to me.

Any IDEAS?

Imports System.Runtime.InteropServices

'* C++ Conversions Aliases.

Imports DWORD = System.UInt32

Imports BOOL = System.Boolean

Imports PDWORD = System.IntPtr

Imports CLONG = System.UInt32

Imports Pointer = System.IntPtr

Public Function GetTCPdata()

Dim MIB_TCPROW As New MIB_TCPROW_OWNER_PID

Dim AF_INET As Integer = 2 ' = IP version 4

Dim IptrToTableSize As IntPtr =
Marshal.AllocHGlobal(Marshal.SizeOf(GetType(System .UInt32)))

Dim RetVal As DWORD

'Get the Size of the TCP TABLE

RetVal = GetExtendedTcpTable(IntPtr.Zero, IptrToTableSize, 0, AF_INET, 5, 0)

Dim iptrToTcpTableArray As IntPtr

'Allocate space in the pointer

iptrToTcpTableArray = Marshal.AllocHGlobal(Marshal.SizeOf(IptrToTableSiz e))

' Trying to get a Pointer to the TCP table

RetVal = GetExtendedTcpTable(iptrToTcpTableArray, IptrToTableSize, 0,
AF_INET, 5, 0)

MessageBox.Show(RetVal.ToString & ", TCP Table Size " &
IptrToTableSize.ToString)

Marshal.FreeHGlobal(iptrToTcpTableArray)

Return 0

End Function

'*** API DECLARE ****

'C++ Original

'DWORD GetExtendedTcpTable(

' PVOID pTcpTable,

' PDWORD pdwSize,

' BOOL bOrder,

' ULONG ulAf,

' TCP_TABLE_CLASS TableClass,

' ULONG Reserved

');

'VB.net Conversion ?

Public Declare Unicode Function GetExtendedTcpTable Lib _

"IPHLPAPI.DLL" _

( _

ByVal pTcpTable As IntPtr, _

ByVal pDwSize As Integer, _

ByVal bOrder As BOOL, _

ByVal ulAf As Integer, _

ByVal TCP_TABLE_CLASS As Integer, _

ByVal Reserved As Integer) As Integer
Jan 3 '07 #1
2 3247
>'VB.net Conversion ?
>
Public Declare Unicode Function GetExtendedTcpTable Lib _

"IPHLPAPI.DLL" _

( _

ByVal pTcpTable As IntPtr, _

ByVal pDwSize As Integer, _

ByVal bOrder As BOOL, _

ByVal ulAf As Integer, _

ByVal TCP_TABLE_CLASS As Integer, _

ByVal Reserved As Integer) As Integer

pDwSize should be ByRef.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 3 '07 #2
Thanks,

That did it; returns zero now.

PS nice site "DotNotInterop"

Mike.

"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:OV**************@TK2MSFTNGP02.phx.gbl...
'VB.net Conversion ?

Public Declare Unicode Function GetExtendedTcpTable Lib _

"IPHLPAPI.DLL" _

( _

ByVal pTcpTable As IntPtr, _

ByVal pDwSize As Integer, _

ByVal bOrder As BOOL, _

ByVal ulAf As Integer, _

ByVal TCP_TABLE_CLASS As Integer, _

ByVal Reserved As Integer) As Integer


pDwSize should be ByRef.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Jan 3 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a...
36
by: AussieRules | last post by:
Hi, I want to use the user color scheme to set the color of my forms. I now I have to use the. System.Drawing.SystemColors, but which color is the color of a form background as used in other...
12
by: Joel Byrd | last post by:
I'm having a little problem with using type-ahead functionality for an auto-suggest box. Sometimes, when I start to type something and the type-ahead shows up, the AJAX will send a request query...
0
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
6
by: per9000 | last post by:
An interesting/annoying problem. I created a small example to provoke an exception I keep getting. Basically I have a C-struct (Container) with a function-pointer in it. I perform repeated calls...
3
by: StephQ | last post by:
I'm writing some algorithms that works on generic functions using boost::bind. My problem is that class templates can never be deduced. In the simplest cases I just write the class like: ...
5
by: jbenner | last post by:
I have opened a PMR for this with IBM, and am not asking for advice from the DB2 DBA community. I am posting this as an FYI that DB2 Health Monitor, even at the latest version of DB2, still can cause...
6
by: pauldepstein | last post by:
Let double NR( double x, double(*)(const double&) f ) be the signature of a Newton-Raphson function NR. Here, f is a function which returns a double and accepts a const double&. The aim of...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.