![]() |
ICS Port Mapping (WinXP Internetfreigabe)
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo zusammen,
Ich frage mich, ob es möglich ist, mit Delphi auf folgende Einstellungen zuzugreifen: Bild ist im Anhang zu sehen. (Hier sollte ein Bild der freigegebenen Ports der WinXP Internetfreigabe zu sehen sein) Laut ![]() Beste Grüße, Dani [edit=sakura] Bild als Anhang, damit es für immer erhalten bleibt. Mfg, sakura[/edit] [edit=sakura] Mfg, sakura[/edit] |
Re: ICS Port Mapping (WinXP Internetfreigabe)
Geh mal auf Projekt -> Typbibliothek importieren..., dann wählst du "NetCon 1.0 Type Library" aus und klickst auf Installieren. Somit hast die ganzen Interface-Deklarationen schon mal.
|
Re: ICS Port Mapping (WinXP Internetfreigabe)
Meine Güte, all die Möglichkeiten...
Danke vielmals! |
Re: ICS Port Mapping (WinXP Internetfreigabe)
Habs aufgegeben, bin an der Enumeration gescheitert :(
Naja, jetzt muss halt das JavaScript Beispiel herhalten... benötigte Zeit, um 10 000 Ports freizugeben: 8,3 Stunden :mrgreen:
Code:
ICSSC_DEFAULT = 0;
ICSTT_NAME = 0; ICSTT_IPADDRESS = 1; // from netcon.idl //NCM_SHAREDACCESSHOST_LAN = 8; //NCM_SHAREDACCESSHOST_RAS = 9; NAT_PROTOCOL_TCP = 6 NAT_PROTOCOL_UDP = 17 // from netcon.idl NCCF_SHARED = 0x0100; // Connection is shared NCCF_FIREWALLED = 0x0400; // Connection is firewalled WScript.Echo ("Starting...."); Main(); WScript.Echo ("Ending...."); function Main() { var objShare = new ActiveXObject("HNetCfg.HNetShare.1"); if (objShare == null) WScript.Echo ("failed to create HNetCfg.HNetShare object!"); else DoTheWork (objShare); return; } function DoTheWork (objShare) { var objEveryConnColl = objShare.EnumEveryConnection; if (objEveryConnColl == null) WScript.Echo ("failed to get EveryConnectionCollection!"); else { // enum INetConnections until props are correct var objEveryEnum = new Enumerator (objEveryConnColl); if (objEveryEnum == null) WScript.Echo ("failed to create Enumerator from EveryConnectionCollection"); else { for (objEveryEnum.moveFirst(); !objEveryEnum.atEnd(); objEveryEnum.moveNext()) { var objNetConn = objEveryEnum.item(); if (objNetConn == null) WScript.Echo ("can't get any net connections!"); else { var objNetConnProps = objShare.NetConnectionProps (objNetConn); if (objNetConnProps == null) WScript.Echo ("can't get net connection props!"); else { if ((objNetConnProps.Characteristics & NCCF_SHARED) || (objNetConnProps.Characteristics & NCCF_FIREWALLED)) { // found one! var objShareConf = objShare.INetSharingConfigurationForINetConnection (objNetConn); if (objShareConf == null) WScript.Echo ("can't make INetSharingConfiguration object!"); else { var i; fordings = 1; for (i=1; 1<10001; i++) {AddAsymmetricPortMapping (objShareConf, i, i)}; // WScript.Echo ("added a port mapping named 'Ben's Port Mapping'."); } } } } } } } // do other work here. // when you're done, // clean up port mapping WScript.Echo ("cleaning up"); //if (objShareConf != null) // DeletePortMapping (objShareConf, NAT_PROTOCOL_TCP, 555, 444); } function AddAsymmetricPortMapping (objShareConf, iPort, ePort) { // in case it exists already.... DeletePortMapping (objShareConf, NAT_PROTOCOL_TCP, iPort, ePort); var objPortMapping = objShareConf.AddPortMapping ( "Automated Port Mapping:" + iPort, NAT_PROTOCOL_TCP, iPort, ePort, 0, "paps", ICSTT_NAME); // or "192.168.0.2", ICSTT_IPADDRESS); if (objPortMapping != null) { WScript.Echo ("just added another Port:" + iPort); objPortMapping.Enable(); WScript.Echo ("just enabled another port mapping!"); } else WScript.Echo ("failed to add asymmetric port mapping!"); } function DeletePortMapping (objShareConf, typeProtocol, iExternalPort, iInternalPort) { // enum, deleting match, if any var objPMColl = objShareConf.EnumPortMappings (ICSSC_DEFAULT); if (objPMColl == null) WScript.Echo ("can't get 'every' collection!"); else { var varEnumerator = new Enumerator (objPMColl); if (varEnumerator != null) { for (varEnumerator.moveFirst(); !varEnumerator.atEnd(); varEnumerator.moveNext()) { var objPortMapping = varEnumerator.item(); if (objPortMapping != null) { var objPMProps = objPortMapping.Properties; if (objPMProps != null) { if ((objPMProps.IPProtocol == typeProtocol ) && (objPMProps.ExternalPort == iExternalPort) && (objPMProps.InternalPort == iInternalPort)) { objPortMapping.Delete(); // or objShareConf.RemovePortMapping (objPortMapping); WScript.Echo ("just deleted " + typeProtocol + ", " + iExternalPort + ", " + iInternalPort + "!") } } } } } } } |
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:11 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz