To call GetCost you have to use the COM interface. If you need to make this particular call, i.e. Pass NULL instead of the IP address in GetCost , then you will need to define the COM interface yourself to satisfy your needs, for example. eg:
using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [ComImport, Guid("DCB00C01-570F-4A9B-8D69-199FDBA5723B"), ClassInterface(ClassInterfaceType.None)] public class NetworkListManager : INetworkCostManager { [MethodImpl(MethodImplOptions.InternalCall)] public virtual extern void GetCost(out uint pCost, [In] IntPtr pDestIPAddr); } [ComImport, Guid("DCB00008-570F-4A9B-8D69-199FDBA5723B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface INetworkCostManager { void GetCost(out uint pCost, [In] IntPtr pDestIPAddr); }
Then you can get the cost information as follows:
new NetworkListManager().GetCost(out uint cost, IntPtr.Zero);
If you do not have a requirement to pass NULL to GetCost , you can simply add a link to the COM type library “List List 1.0 Type Library”, set “Insert Interaction Types” to false and use these definitions .
source share