Netzkonfiguration
-
Hallo, ich möchte ein Programm schreiben, mit dessen Hilfe man die ganze Netzwerkeinstellung (IP-Adresse, Subnetmaske, Standardgateway, Host-Name usw. ) mit einem einzigen Button-Klick einstellen kann. Hat vielleicht schon jemand so etwas ähnliches programmiert bzw. weiß jemand wo ich mehr Informationen zu diesen Funktionen bekommen kann? Programmieren will ich es mit dem Borland C++ Builder 5.0. Währe sehr froh wenn mir jemand weiterhelfen könnte.
P.S.: Das Programm sollte später unter Win98 laufen.
-
schau mal hier nach:
http://msdn.microsoft.com/library/en-us/iphlp/iphlp/ip_helper_start_page.aspich hab mal ein programm geschrieben mit dem man die konfiguration auslesen konnte. ich denke das setzen/verändern der konfiguration sollte ähnlich funktionieren.
lg
achim
-
Dieser Thread wurde von Moderator/in Jansen aus dem Forum VCL/CLX (Borland C++ Builder) in das Forum WinAPI verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
Bei www.codeproject.com solltest du auch einiges finden
-
Danke erstmal für eure Antwort. Werde mich mal da versuchen einzuarbeiten. Leicht sieht es aber nicht aus.
-
Hallo zusammen,
nach euren Tips habe ich mir mal die ganzen Codes und Beispiele angeschaut, doch so richtig weiter bin ich nicht gekommen. Gibt es nicht vielleicht auch ein Beispiel für den Borland C++ Builder?
Das würde mich wesentlich weiter helfen.
-
Hallo zusammen,
kennt sich jemand mit der Funktion AddIPAddress (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/createipnetentry.asp) aus?
Ich hab sie getestet und es hatte auch den anschein das es funktionierte aber als ich dann die IP in der Netzwerkkunfiguration angeschaut habe war da noch immer die alte eingetragen. Muss ich da vorher noch was anderes machen z.B. Konfiguration löschen etc.?Gruß Carlos
-
Zeig doch mal Code. Evtl. kann dir ja geholfen werden.
-
Hallo
mittlerweile habe ich wenigstens herausgefunden, dass die IP doch gesetzt wird und zwar sieht man diese zusätzlich als weiter IP in der Auflistung (angezeigt mit ipconfig/all) Verbindungsspezifisches DNS-Suffix:
Beschreibung. . . . . . . . . . . : SiS 900-Based PCI Fast Ethernet Adaper
Physikalische Adresse . . . . . . : 00-40-CA-C2-06-CD
DHCP aktiviert. . . . . . . . . . : Ja
Autokonfiguration aktiviert . . . : Ja
IP-Adresse. . . . . . . . . . . . : 192.168.0.27
Subnetzmaske. . . . . . . . . . . : 255.255.255.0
IP-Adresse. . . . . . . . . . . . : 192.168.178.20
Subnetzmaske. . . . . . . . . . . : 255.255.255.0
Standardgateway . . . . . . . . . : 192.168.178.1
DHCP-Server . . . . . . . . . . . : 192.168.178.1
DNS-Server. . . . . . . . . . . . : 192.168.178.1Mit "DeleteIPAddress" wird die IP wieder gelöscht. Das ist auch OK aber wie kann ich zuerst die vorhandene IP löschen und dann eine endgültige IP setzen?
#include <stdio.h> #include <conio.h> #include <winsock.h> #include "iphlpapi.h" #include "Winbase.h" #include "windows.h" int main(void) { // Before calling AddIPAddress we use GetIpAddrTable to get // an adapter to which we can add the IP. PMIB_IPADDRTABLE pIPAddrTable; DWORD dwSize = 0; DWORD dwRetVal = 0; pIPAddrTable = (MIB_IPADDRTABLE*) malloc( sizeof( MIB_IPADDRTABLE) ); // Make an initial call to GetIpAddrTable to get the // necessary size into the dwSize variable if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) { GlobalFree( pIPAddrTable ); pIPAddrTable = (MIB_IPADDRTABLE *) malloc ( dwSize ); } // Make a second call to GetIpAddrTable to get the // actual data we want if ( (dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 )) == NO_ERROR ) { printf("\tAddress: %ld\n", pIPAddrTable->table[1].dwAddr); printf("\tMask: %ld\n", pIPAddrTable->table[1].dwMask); printf("\tIndex: %ld\n", pIPAddrTable->table[1].dwIndex); printf("\tBCast: %ld\n", pIPAddrTable->table[1].dwBCastAddr); printf("\tReasm: %ld\n", pIPAddrTable->table[1].dwReasmSize); } else { printf("Call to GetIpAddrTable failed.\n"); } // IP and mask we will be adding UINT iaIPAddress; UINT imIPMask; iaIPAddress = inet_addr("192.168.0.27"); imIPMask = inet_addr("255.255.255.0"); // Variables where handles to the added IP will be returned ULONG NTEContext = 0; ULONG NTEInstance = 0; if ( (dwRetVal = AddIPAddress(iaIPAddress, imIPMask, pIPAddrTable->table[1].dwIndex, &NTEContext, &NTEInstance) ) == NO_ERROR) { printf("\tIP address added.\n"); } else { printf("Error adding IP address.\n"); LPVOID lpMsgBuf; if (FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwRetVal, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL )) { printf("\tError: %s", lpMsgBuf); } LocalFree( lpMsgBuf ); } // Delete the IP we just added using the NTEContext // variable where the handle was returned if ((dwRetVal = DeleteIPAddress(NTEContext)) == NO_ERROR) { printf("\tIP Address Deleted.\n"); } else { printf("\tCall to DeleteIPAddress failed.\n"); } ULONG NTEContextx = 0; NTEContextx = NTEContext-1; if ((dwRetVal = DeleteIPAddress(NTEContextx)) == NO_ERROR) { printf("\tIP Address Deleted.\n"); } else { printf("\tCall to DeleteIPAddress failed.\n"); } getche(); return 0; }
-
hi,
fuer sowas gibt es doch schon ein cmd-tool, netsh nennt sich das.
gruss
msp
-
ich weiß, aber leider funktioniert netshell nicht unter Win98.
Auf cmd-tools wollte ich aber wenn es geht ganz verzichten.Gruß Carlos