服装营销方案:C++程序如何转换为MATLAB的MEX文件

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/01 07:14:25
以下这段程序可以转换吗?
具体步骤?
#include " stdio.h"
#include " stdlib.h"
# include "Winsock2.h"
#include " iphlpapi.h"
typedef DWORD (CALLBACK*PSARP) (
IPAddr DestIP, / /目的主机IP地址
IPAddr SrcIP, / / 源主机IP地址
PULONG pMacAddr, / / 返回的MAC地址
PULONG PhyAddrLen, / / 返回MAC地址的长度
addr) ; / /定义结构体
) ;
void main ( int argc, char**argv )
{
PSARP pSARP ;
HINSTANCE hInst; / /实例句柄
hInst =LoadLibrary( " iphlpapi.dll" ) ; / /加载IP Helper API所需的库文件
pSARP = ( PSARP) GetProcAddress ( hInst, " SendARP" ) ; / /获取SendARP函数的地址
/ /处理命令行参数
if ( argc ! = 2 )
{
printf ( " Get aMacAddress from host in a segment! \n" ) ;
printf ( "Usage: \n \GetMac. exe [Host IP] \n \n" ) ;
printf ( " Example: \n \GetMac. exe 192. 168. 0. 1 \n \n" ) ;
exit (0) ;
}
printf ( " \n IpAddress: % s\n" , argv[ 1 ] ) ;
int nRemoteAddr = inet_addr( argv[ 1 ] ) ; / /发送ARP查询包获得远程MAC地址
unsigned charmacAddress[ 6 ];
ULONG macAddLen = 6;
int iRet = pSARP ( nRemoteAddr,NULL, ( PULONG) &macAddress, &macAddLen) ;
if ( iRet = =NO_ERROR)
{
printf ( "MacAddress: " ) ;
for ( int i = 0; i < 6; i + + ) / /格式化输出获取的MAC地址
{
printf ( " %. 2x" ,macAddress[ i ] ) ;
if ( i < 5) p rintf ( " - " ) ;
}
}
else
printf ( " SendARP Error: % d \n" , GetLastError( ) ) ;
printf ( " \n" ) ;
}