|
unsigned char Table[8] = {0xC, 0xA, 0x13, 0x9,0xC,0xB,0xA,0x8};
unsigned long GenRegCode(CHAR * name, int len)
{
CString temp;
int i, j;
unsigned long ID =0;
for(i=3,j=0; i<len; i++,j++)
{
if(j>7)
j=0;
ID+=name[i]*Table[j];
}
return ID;
}
void CTraceMeDlg::OnRegist()
{
// TODO: Add your control notification handler code here
CString str1;
CString test;
unsigned long str2;
char* buf;
GetDlgItemText(IDC_Name,str1);
buf = (LPSTR)(LPCTSTR)str1;
str2 = GenRegCode(buf,strlen(str1));
test.Format("%ld",str2);
SetDlgItemText(IDC_ID, test);
} |
|