,怎么将字符串里的16进制值赋给WORD数组

求助,如何将字符串里的16进制值赋给WORD数组
比如:

CString   str   =   "0x0650 ";
WORD   buff   =   new   WORD[1];

请问如何把str里的16进制值直接赋给buff啊,也就是buff[0]   =   0x0650

急死了,请高人出手帮助啊!!

------解决方案--------------------
char szNum[8]= "0xBA09 "; //假设字符串以0x起始,后接4个以内的字符(0-9, a-f, A-F)

char *p=szNum+2;
char ch;
unsigned short wNum=0;
while(ch=*p)
{
wNum < <=4;
if(ch> = 'A ' && ch <= 'F ') ch-=( 'A '-10);
else if(ch> = 'a ' && ch <= 'f ') ch-=( 'a '-10);
else ch-= '0 ';
wNum|=ch;
p++;
}
------解决方案--------------------
CString str = "0x0650 ";
WORD buff = new WORD[1];

for (i=2,j=0;i <str.GetLength();i+=4,j++)
{
int hi_byte1=(str.GetAt(i)- '0 ') < <4;
int hi_byte2=(str.GetAt(i+1)- '0 ');
int hi_byte=hi_byte1 | hi_byte2;

int lo_byte1=(str.GetAt(i+2)- '0 ') < <4;
int lo_byte2=(str.GetAt(i+3)- '0 ');
int lo_byte=hi_byte1 | hi_byte2;

buff[j]=MAKEWORD((BYTE)lo_byte,(BYTE)hi_byte);

}
------解决方案--------------------
修正一下,上面的有问题
for (i=2,j=0;i <str.GetLength()&& str.GetLength()> =4;i+=4,j++)
{
char temp=str.GetAT(i);
int hi_byte1
if (temp> = '0 ' && temp <= '9 ')
hi_byte1=(temp- '0 ') < <4;
if (toupper(temp)> = 'A ' && toupper(temp) <= 'F ')
hi_byte1=(toupper(temp)- 'A ') < < 4;

temp=str.GetAT(i+1);
int hi_byte2
if (temp> = '0 ' && temp <= '9 ')
hi_byte2=(temp- '0 ') < <4;
if (toupper(temp)> = 'A ' && toupper(temp) <= 'F ')
hi_byte2=(toupper(temp)- 'A ') ;

int hi_byte=hi_byte1 | hi_byte2;

temp=str.GetAT(i+2);
int low_byte1
if (temp> = '0 ' && temp <= '9 ')
low_byte1=(temp- '0 ') < <4;
if (toupper(temp)> = 'A ' && toupper(temp) <= 'F ')
low_byte1=(toupper(temp)- 'A ') < < 4;

temp=str.GetAT(i+3);
int low_byte2
if (temp> = '0 ' && temp <= '9 ')
low_byte2=(temp- '0 ') < <4;
if (toupper(temp)> = 'A ' && toupper(temp) <= 'F ')
low_byte2=(toupper(temp)- 'A ') ;

int low_byte=low_byte1 | low_byte2;
buff[j]=MAKEWORD((BYTE)low_byte,(BYTE)hi_byte);
}

------解决方案--------------------
再次修正一下,上面的有问题
for (i=2,j=0;i <str.GetLength()&& str.GetLength()> =4;i+=4,j++)
{
////////////////////////////////////
char temp=str.GetAT(i);
int hi_byte1
if (temp> = '0 ' && temp <= '9 ')
hi_byte1=(temp- '0 ') < <4;
if (toupper(temp)> = 'A ' && toupper(temp) <= 'F ')
hi_byte1=(toupper(temp)- 'A ') < < 4;
////////////////////////////////////
temp=str.GetAT(i+1);
int hi_byte2
if (temp> = '0 ' && temp <= '9 ')