Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I would like to call an API which is written in mfc

This is the API

BOOL __stdcall SearchMAC(LPCTSTR strIP,CString &strMac)

I tried to declare the API like below

C#
[DllImport("DllEx.dll", EntryPoint = "SearchMAC", CharSet = CharSet.Unicode)]
        public static extern unsafe bool SearchMAC(string strIP,  string MAC);


and called the API like below

C#
string mac = "02ABCDEFGIJ";
                bool x = DLL.SearchMAC("192.168.1.100", mac);


But it it always returns false.

Kindly help me to read the MAC address as I am new to c#.

Thank you
Posted
Comments
[no name] 6-May-14 7:20am    
Why are you doing that at all? Get the MAC using WMI in C# directly.

1 solution

If all you want is to get the MAC address I would suggest not trying to use the MFC dll and to use the updated approach.

See: http://msdn.microsoft.com/en-us/library/vstudio/system.net.networkinformation.physicaladdress[^]

and

how to get mac address using C#.net[^]
 
Share this answer
 
Comments
srini45 6-May-14 9:58am    
Sorry forgot to mention. Using that dll I am trying to get the MAC address of external electronc board
ZurdoDev 6-May-14 10:09am    
The fact that it is returning a value and not throwing an error tells me it is calling your dll. Perhaps something else is missing?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900