直接给出实例: void CK390_TestApp::OnGprsTest() { // TODO: Add your command handler code here int dwRet=0; HDC hdc; hdc = CreateDC(0,0,0,0);//获得设备句柄 RETAILMSG(1,(_T("GPRS Test./n"))); InitGPIOAddr(); //232CTR->GPJ9 =0 -> GPRS //GSMPWR->GPJ11=1 //GSMOP1->GPJ10=0 //WAKE ->GPJ12=0 s2440IOP->GPJCON = ((s2440IOP->GPJCON &~ (0x3<<18)) | (1<<18)); s2440IOP->GPJDAT &=~(1<<9); s2440IOP->GPJCON = ((s2440IOP->GPJCON &~ (0x3<<22)) | (1<<22)); s2440IOP->GPJDAT &=~(1<<11); Sleep(100); s2440IOP->GPJDAT |=(1<<11); s2440IOP->GPJCON = ((s2440IOP->GPJCON &~ (0x3<<20)) | (1<<20)); s2440IOP->GPJDAT &=~(1<<10); s2440IOP->GPJCON = ((s2440IOP->GPJCON &~ (0x3<<24)) | (1<<24)); s2440IOP->GPJDAT &=~(1<<12); Sleep(100); s2440IOP->GPJDAT |=(1<<12); Sleep(350); s2440IOP->GPJDAT &=~(1<<12); dwRet=ExtTextOut(hdc, 0, 140, ETO_CLIPPED, NULL, _T("K390 test."), strlen("K390 test."), NULL); if(dwRet==0) { dwRet = GetLastError(); printf("error = %d ../n", dwRet); } if(!COMInit()) { printf("COMInit ERROR!!/r/n"); } else { char *recvAt[1]; char tmpbuf[3]="OK"; int i=0; //char BufTest[3]="OK"; TCHAR BufTest[3]; i=MultiByteToWideChar(CP_ACP,0,tmpbuf,-1,BufTest,0); i=MultiByteToWideChar(CP_ACP,0,tmpbuf,-1,BufTest,i); //memcpy(BufTest,tmpbuf,strlen(tmpbuf)); ExtTextOut(hdc, 0, 100, ETO_CLIPPED, NULL,BufTest, _tcslen(BufTest), NULL); recvAt[0] = tmpbuf; int ret=0; //ret = GPRS_AT("AT",recvAt,1); ret = GPRS_AT("AT+GMI",recvAt,1);//lqm test. if(ret == -3) printf("GPRS_AT ret =%d/r/n",ret); } DeleteDC(hdc); } 两句MultiByteToWideChar()函数解决char到TCHAR的问题。 转换的目的在于ExtTextOut()函数能够正常输出char字符。