DWORD类型IP地址转换成CSTRING

来源:互联网 发布:php 正则表达式匹配 编辑:程序博客网 时间:2024/06/05 20:30
CString GetIPStringFromDWORD(DWORD IP)
{
CString strA(_T("")), strB(_T("")), strC(_T("")), strD(_T(""));
DWORD dwIP = IP;


strD.Format(_T(".%d"), dwIP % 256);
dwIP /= 256;


strC.Format(_T(".%d"), dwIP % 256);
dwIP /= 256;


strB.Format(_T(".%d"), dwIP % 256);
dwIP /= 256;


strA.Format(_T("%d"), dwIP % 256);


return strA + strB + strC + strD;
}
0 0