| Autor |
Beitrag |
Fighter#1
      
Beiträge: 787
Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
|
Verfasst: Sa 11.02.06 11:52
SO als erstes noch kurz, benutz ich den Befehl richtig ?
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8:
| var zahl:Cardinal; wahr:boolean; begin zahl2:=True; iphlpapi.GetTcpTable(nil,zahl,wahr); Label1.Caption:=IntToStr(zahl); end; |
Was kann man damit machen?
Kann der Befehl in einen Array und es können dann versch. Sachen ausgelesen werden ?
_________________ Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
|
|
BenBE
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: Sa 11.02.06 14:10
Wenn ich mir die Deklaration und den dazu gehörigen Eintrag im MSDN anschaue:
C#-Quelltext 1: 2: 3: 4: 5:
| DWORD GetTcpTable( PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder ); |
Nein
Um's vollständig zu machen:
| MSDN Library \ Plattform SDK August 2004: | GetTcpTable
The GetTcpTable function retrieves the TCP connection table.
C#-Quelltext 1: 2: 3: 4: 5:
| DWORD GetTcpTable( PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder ); |
Parameters
pTcpTable
[out] Pointer to a buffer that receives the TCP connection table as a MIB_TCPTABLE structure.
pdwSize
[in, out] On input, specifies the size of the buffer pointed to by the pTcpTable parameter.
On output, if the buffer is not large enough to hold the returned connection table, the function sets this parameter equal to the required buffer size.
bOrder
[in] Specifies whether the connection table should be sorted. If this parameter is TRUE, the table is sorted in the order of:
1 = Local IP address
2 = Local port
3 = Remote IP address
4 = Remote port
Return Values
If the function succeeds, the return value is NO_ERROR.
If the function fails, the return value is one of the following error codes.
Return code --> Description
ERROR_INSUFFICIENT_BUFFER --> The buffer pointed to by the pTcpTable parameter is not large enough. The required size is returned in the DWORD variable pointed to by the pdwSize parameter.
ERROR_INVALID_PARAMETER --> The pdwSize parameter is NULL, or GetTcpTable is unable to write to the memory pointed to by the pdwSize parameter.
ERROR_NOT_SUPPORTED --> This function is not supported on the operating system in use on the local system.
Other --> Use FormatMessage to obtain the message string for the returned error.
Example Code
The following example retrieves the TCP connection table and prints the state of each connection.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41:
| PMIB_TCPTABLE pTcpTable;
pTcpTable = (MIB_TCPTABLE*) malloc(sizeof(MIB_TCPTABLE)); DWORD dwSize = 0;
if (GetTcpTable(pTcpTable, &dwSize, TRUE) == ERROR_INSUFFICIENT_BUFFER) { GlobalFree(pTcpTable); pTcpTable = (MIB_TCPTABLE*) malloc ((UINT) dwSize); }
if ((dwRetVal = GetTcpTable(pTcpTable, &dwSize, TRUE)) == NO_ERROR) { for (int i = 0; i < (int) pTcpTable->dwNumEntries; i++) { printf("State: %ld\n", pTcpTable->table[i].dwState); } }
else { printf("\tCall to GetTcpTable failed.\n"); LPVOID lpMsgBuf; if (FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwRetVal, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL )) { printf("\tError: %s", lpMsgBuf); } LocalFree( lpMsgBuf ); } |
Requirements
Client: Requires Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0 SP4 and later, Windows Me, or Windows 98.
Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0 SP4 and later.
Header: Declared in Iphlpapi.h.
Library: Use Iphlpapi.lib. |
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
|