《测控系统软件设计》实验指导书实验一C++BuilderIDE认识实验内容:1、运用C++Builder编写一个Windows应用程序;2、运用CB编写一个控制台程序。要求:熟练掌握运用CB进行windows应用程序和控制台程序的开发、编写、编译及调试过程。1.应用程序编写—系统信息获取1)创建如下图之界面2)组件设置如下表组件名属性设置TformNameForm1Caption系统硬件信息BorderStylebsDialogTlabel1NameLabelCPUCaptionCPU:AutoSizeFALSETlabel2NameLabelMemoryCaption内存:AutoSizeFALSETlabel3NameLabelDiskCaption硬盘:AutoSizeFALSETlabel4NameLabelVideoCaption显示器:AutoSizeFALSETbuttonNamebtn_showCaption显示TbuttonNamebtn_quitCaption退出3)代码:#includeRegistry.hppvoid__fastcallTForm1::btn_showClick(TObject*Sender){//获取CPU信息TRegistry*Registry=newTRegistry;AnsiStringstrCPU;try{Registry-RootKey=HKEY_LOCAL_MACHINE;Registry-OpenKey(HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0,true);strCPU=Registry-ReadString(ProcessorNameString);strCPU=strCPU+AnsiString(Registry-ReadInteger(~MHz))+MHz;LabelCPU-Caption=LabelCPU-Caption+strCPU;}__finally{deleteRegistry;}//获取内存状态MEMORYSTATUSmemory;memory.dwLength=sizeof(memory);GlobalMemoryStatus(&memory);LabelMemory-Caption=内存:物理内存(MB)+AnsiString(int(memory.dwTotalPhys/1024/1024))+可用内存(MB):+String(memory.dwAvailPhys/1024/1024);//获取硬盘信息ULARGE_INTEGERFreeSpaceToCall,TotalSpace,FreeSpace;::GetDiskFreeSpaceEx(C:,&FreeSpaceToCall,&TotalSpace,&FreeSpace);LabelDisk-Caption=C盘总空间(MB):+AnsiString(TotalSpace.QuadPart/1024/1024)+可用空间(MB):+AnsiString(FreeSpace.QuadPart/1024/1024);//显示器LabelVideo-Caption=当前分辨率:+AnsiString(Screen-Width)+*+AnsiString(Screen-Height);}void__fastcallTForm1::btn_quitClick(TObject*Sender){Close();}2.控制台程序—公有继承测试代码://类的继承#includeiostream.h#includeconio.hclassA{public:voidget_XY(){coutEntertwonumbersofx,y:;cinxy;}voidput_XY(){coutx=x,y=y'\n';}protected:intx,y;};classB:publicA{public:intget_S(){returns;};voidmake_S(){s=x*y;};//使用基类数据成员x,yprotected:ints;};classC:publicB{public:voidget_H(){coutEnteranumberofh:;cinh;}intget_V(){returnv;}voidmake_V(){make_S();v=get_S()*h;}//使用基类成员函数protected:inth,v;};//主函数voidmain(){AobjA;BobjB;CobjC;coutItisobject_A:\n;objA.get_XY();objA.put_XY();coutItisobject_B:\n;objB.get_XY();objB.make_S();coutS=objB.get_S()endl;coutItisobject_C:\n;objC.get_XY();objC.get_H();objC.make_V();coutV=objC.get_V()endl;getch();}