قم باضافة هذا الملف ل reference
hmetcfg.dll
Dim m As New NetSharingManager
m.INetSharingConfigurationForINetConnection.AddPortMapping("Test", 6, 5000, 5000, 10, "compnametst2", 10)
الكود المفروض انه سليم وممكن مراجعته من
http://msdn2.microsoft.com/en-us/library/aa365937.aspx
لكنه يعطي رسالة خطأ
argument not optional
=========================================================
هذا كود ثاني لحل نفس المشكلة
'And then puts up a prompt waiting for the user
'to be finished transferring files
'Set theNatter = CreateObject("HNetCfg.NATUPnP")
'
'Dim mappingPorts
'
'Set mappingPorts = theNatter.StaticPortMappingCollection
'
''We add a new port saying that externally accept from port 1024
''route to internal port 1024 on computer with IP 192.168.1.101
''Enabling the forward, and giving a name of the forward to be IRC
'
'mappingPorts.Add 1024, "TCP", 2000, "192.168.1.101", True, "IRC"
'
'MsgBox ("Total number of ports after add is " & mappingPorts.Count & ". Hit OK when you're done transfering")
'
''To uniquely specify a forward, you give the external port
''and the protocol - here we remove the forward that we added
'
'mappingPorts.Remove 1024, "TCP"
MsgBox ("We're done and the total number of ports is " & mappingPorts.Count)
لكنه يعطي مشكلة
can't create object
ممكن المساعدة لو سمحتم
شكرا