以下是只允许用户名中包含数字和字母及两个下划线
bool CRegisterNewUserDlg::StrFormat(CString pStr)
{for (int i = 0; i < pStr.GetLength(); i++)
{
if ((pStr[i] >= '0' && pStr[i] <= '9') ||
(pStr[i] >= 'a' && pStr[i] <= 'z') ||
(pStr[i] >= 'A' && pStr[i] <= 'Z') ||
pStr[i] == '-' || pStr[i] == '_')
{
continue;
}
else
{
return false;
}
}
return true;
}