Protect cBot with machine ID - Error iphlpapi.dll
20 Apr 2023, 18:15
maybe some c# eperts can help me.
I'm trying to protect a cbot based on machine ID (MAC address).
but wenn I use my code I receive the error: "Crashed in OnTick with DllNotFoundException: Unable to load DLL 'iphlpapi.dll' or one of its dependencies: 0x80070005 (E_ACCESSDENIED)".
I checked my windows folder, the 'iphlpapi.dll' is in there. So how could I solve the problem? Any ideas what the reason is and how to solve it?
here is the code I use for checking the machine ID:
public string getMacAddress()
String firstMacAddress = NetworkInterface
.Where(nic => nic.OperationalStatus == OperationalStatus.Up && nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)
.Select(nic => nic.GetPhysicalAddress().ToString())
21 Apr 2023, 05:12
First of all, the error message says, "Access Denied". So have you tried granting your cBot full access?
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
Second, if that doesn't work, and you've already added it as a "reference" to your solution in cTrader, then you'll probably have to use the DLL Import directive in C#.
And for that, I suggest you try using Google to find examples as there's plenty out there.
Blah blah blah :-)