您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 企业文化 > Windows CE 应用与编程
WindowsCE1WindowsCE®®········•••••WindowsCE2WindowsCE12345NOTES:WindowsCE2.11.ControlPanelCommunications.2.WinCE..3.TCP/IP(ControlPanelNetwork)IPDHCP.IP.4.regsave.exe5.6.WinCEWindows95\95\nt\2000WinCEWindows95/98/NT/2000.net/?netviewcomputername|/DOMAIN:domainnamenetuse[localname|*][remotename][/user:username][/d]Example:netview\\MyServer\MyShareDirectorycd“\\MyServer\MyDocument”cd\\MyServer\MyShareDirectory1.WindowsCE(ip)2.eMbeddedVisualC++.net3.Tools“ConfigurePlatformManager…”4.SDK(e.g.Advantech_X86)5.“Properties…”6.“TCP/IPTransportforWindowsCE”7.“Configure”8.“FixedPort”“OK”9.“Advanced”10.“ManualServer”“OK”11.“Test”12..OK.13.WinCE14.WindowsCE2.2eVC1Win32Win32HelloWorldeMbeddedVisualC++.net.FileNew,ProjectsWCEApplication.HelloW32,.SDK(e.g.Win32(WCEx86)andWin32(WCEx86em)).OK.WCEApplication-Step1of1AtypicalHelloWorldapplicationFinish.Win32(Workspace)BuildBuildHelloW32.exeWindowsCE2MFCMFCeMbeddedVisualC++4.0.FileNew,ProjectsWCEMFCAppWizard(exe).HelloMFC,SDK(e.g.Win32(WCEx86)andWin32(WCEx86em)).OK.Finish.BuildBuildHelloMFC.exe.WindowsCE3eVCUNO-2050APIUNO-2050DI/O,Counter“ADS2050.DLL”I/OWindowsDLLeMbeddedVisualC++4.0ADS2050.hADS2050.libDLL1)DRV_DeviceOpen()I/O“0”“0”2)DRV_DeviceClose()DRV_DeviceOpen()DRV_DeviceOpen()“0”“0”EX1:DIGINDIGOUTUNO-2050I/ODIGIN:#includestdafx.h#include..\..\include\ADS2050.hvoidErrorHandler(LONGlDrvHandle,DWORDdwErrCde,BOOLbClose);intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPTSTRlpCmdLine,intnCmdShow){DWORDdwErrCde;ULONGlDevNum;LONGlDriverHandle;USHORTusState;inti;//Step1:Displayhardwareandsoftwaresettingsforrunningthisexampleprintf(Digitalinputviaportoutputandbitnumber....\n\n);//Step2:IftheOnboardI/O,it'sdevicenumberiszero.lDevNum=0;//Step3:OpendevicedwErrCde=DeviceOpen(lDevNum,&lDriverHandle);if(dwErrCde!=SUCCESS){ErrorHandler(lDriverHandle,dwErrCde,FALSE);exit(1);}//Step4:ReadstatefromthespecifiedchanneldwErrCde=DioReadPortByte(lDriverHandle,0,&usState);if(dwErrCde!=SUCCESS){ErrorHandler(lDriverHandle,dwErrCde,TRUE);return0;}printf(\nReadingdataviaport=0x%x\n\n,usState);//Step5:ReadStatefromeachbitfrom0to7for(i=0;i=7;i++){dwErrCde=DioReadBit(lDriverHandle,0,i,&usState);if(dwErrCde!=SUCCESS){ErrorHandler(lDriverHandle,dwErrCde,TRUE);return0;}printf(Readingdataviabits(Bit%d)=0x%1X\n,i,usState);}//Step6:ClosedevicedwErrCde=DeviceClose(&lDriverHandle);printf(\nPressanykeytoexit....);getchar();return0;}/***********************************************************************Function:ErrorHandler*Showtheerrormessageforthecorrespondingerrorcode*input:lDrvHandle,dwErrCde,bClose*return:none**********************************************************************/voidErrorHandler(LONGlDrvHandle,DWORDdwErrCde,BOOLbClose){TCHARszErrMsg[180];charszAnsiMsg[180];if(bClose)DeviceClose(&lDrvHandle);GetErrorMessage(dwErrCde,szErrMsg);//ConvertwidechartoansicharWideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK,szErrMsg,-1,szAnsiMsg,180,NULL,NULL);printf(\nError(%d):%s\n,dwErrCde&0xffff,szAnsiMsg);printf(Programterminated!\n);printf(Pressanykeytoexit....);getchar();getchar();}DIGOUT:#includestdafx.h#include..\..\include\ADS2050.hvoidErrorHandler(LONGlDrvHandle,DWORDdwErrCde,BOOLbClose);intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPTSTRlpCmdLine,intnCmdShow){DWORDdwErrCde;ULONGlDevNum;LONGlDriverHandle;USHORTusState;inti;//Step1:Displayhardwareandsoftwaresettingsforrunningthisexampleprintf(Digitaloutputviaportoutputandbitnumber....\n\n);//Step2:IftheOnboardI/O,it'sdevicenumberiszero.lDevNum=0;//Step3:OpendevicedwErrCde=DeviceOpen(lDevNum,&lDriverHandle);if(dwErrCde!=SUCCESS){ErrorHandler(lDriverHandle,dwErrCde,FALSE);exit(1);}//Step3:ReadbackthecurrentDOvaluedwErrCde=DioGetCurrentDOByte(lDriverHandle,0,&usState);if(dwErrCde!=SUCCESS){ErrorHandler(lDriverHandle,dwErrCde,TRUE);return0;}printf(\nGetcurrentDOviaport=0x%x\n,usState);//Step4:ReadStatefromeachbitfrom0to7for(i=0;i=7;i++){dwErrCde=DioGetCurrentDOBit(lDriverHandle,0,i,&usState);if(dwErrCde!=SUCCESS){ErrorHandler(lDriverHandle,dwErrCde,TRUE);return0;}printf(GetcurrentDOviabits(Bit%d)=0x%1X\n,i,usState);}printf(\nPreparetowritedata,pressanykeytocontinue...\n\n);getchar();//Step5:Preparethewritevalue0x00and0xffdwErrCde=DioWritePortByte(lDriverHandle,0,0xff,0x00);printf(\nWriteportvalueto0x00,pressanykeytocontinue....\n);getchar();dwErrCde=DioWritePortByte(lDriverHandle,0,0xff,0xff);printf(\nWriteportvalueto0xff,pressanykeytocontinue....\n);getchar();//Step6:ReadStatefromeachbitfrom0to7for(i=0;i=7;i++){dwErrCde=DioWriteBit(lDriverHandle,0,i,i%2);if(dwErrCde!=SUCCESS){ErrorHandler(lDriverHandle,dwErrCde,TRUE);return0;}printf(Writebitvalueto0x00(Bit%d)=0x%1X\n,i,i%2);}//Step7:ClosedevicedwErrCde=DeviceClose(&lDriverHandle);printf(\nPressanykeytoexit....);getchar();return0;}/***********************************************************************Function:ErrorHandler*Showtheerrormessageforthecorrespondingerrorcode*input:lDrvHandle,dwErrCde,bClose*return:none************************************************************
本文标题:Windows CE 应用与编程
链接地址:https://www.777doc.com/doc-5352435 .html