如何将mfc dll API转换为c# [英] How to convert mfc dll API to c#

查看:290
本文介绍了如何将mfc dll API转换为c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我想调用一个用mfc编写的API



这是API



BOOL __stdcall SearchMAC(LPCTSTR strIP,CString& strMac)



我试图声明如下API



 [DllImport(  DllEx.dll,EntryPoint =   SearchMAC,CharSet = CharSet.Unicode )] 
public static extern 不安全 bool SearchMAC( string strIP, string MAC);





并调用下面的API



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





但它总是返回false。



请帮我读一下MAC地址,因为我是c#的新手。



谢谢

解决方案

如果您只想获取MAC地址,我建议您不要使用MFC dll并使用更新的方法。



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







如何使用C#.net 获取mac地址[ ^ ]

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

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



and called the API like below

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

解决方案

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[^]


这篇关于如何将mfc dll API转换为c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆