Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:2k
源码类别:

VC书籍

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <registry.hpp>
  4. #pragma hdrstop
  5. #include "Unit1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma resource "*.dfm"
  9. TForm1 *Form1;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.         : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm1::Button1Click(TObject *Sender)
  17. {
  18.   AnsiString PrinterName;
  19.   TRegistry *rg;
  20.   rg=new TRegistry();
  21.   rg->RootKey=HKEY_LOCAL_MACHINE;
  22. //
  23.   rg->OpenKey("\Config\0001\System\CurrentControlSet\Control\Print\Printers",False);
  24.   PrinterName=rg->ReadString("Default");
  25.   if(PrinterName=="")ShowMessage("未安装打印机!");
  26.   else ShowMessage(PrinterName);
  27. //
  28.   rg->CloseKey();
  29.   rg->Free();
  30. }
  31. //---------------------------------------------------------------------------
  32. void __fastcall TForm1::Button2Click(TObject *Sender)
  33. {
  34.   AnsiString ass;
  35.   TRegistry *rg;
  36.   rg=new TRegistry();
  37.   rg->RootKey=HKEY_LOCAL_MACHINE;
  38. //
  39.   Memo1->Clear();
  40.   rg->OpenKey("\Config\0001\Display\Settings",False);
  41.   ass=rg->ReadString("BitsPerPixel");
  42.   Memo1->Lines->Add("颜色(每像素点的位数):"+ass);
  43.   ass=rg->ReadString("Resolution");
  44.   Memo1->Lines->Add("屏幕区域(横向像素、纵向像素):"+ass);
  45.   ass=rg->ReadString("DPILogicalX");
  46.   Memo1->Lines->Add("横向逻辑分辨率:"+ass);
  47.   ass=rg->ReadString("DPILogicalY");
  48.   Memo1->Lines->Add("纵向逻辑分辨率:"+ass);
  49.   ass=rg->ReadString("DPIPhysicalX");
  50.   Memo1->Lines->Add("横向物理分辨率:"+ass);
  51.   ass=rg->ReadString("DPIPhysicalY");
  52.   Memo1->Lines->Add("纵向物理分辨率:"+ass);
  53. //
  54.   rg->CloseKey();
  55.   rg->Free();
  56. }
  57. //---------------------------------------------------------------------------