unsigned long StrToHex(char* str){ unsigned long hex,val; int n; hex=0; for(n=0;n<strlen(str);n++) { if(str[n]>='0' && str[n]<='9') val=(unsigned long)(str[n]-'0'); else if(str[n]>='a' && str[n]<='f') val=((unsigned long)(str[n]-'a'))+0xA; else if(str[n]>='A' && str[n]<='F') val=((unsigned long)(str[n]-'A'))+0xA; else val=0; hex<<=4; hex|=val; } return hex;}