Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:2k
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <registry.hpp>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- AnsiString PrinterName;
- TRegistry *rg;
- rg=new TRegistry();
- rg->RootKey=HKEY_LOCAL_MACHINE;
- //
- rg->OpenKey("\Config\0001\System\CurrentControlSet\Control\Print\Printers",False);
- PrinterName=rg->ReadString("Default");
- if(PrinterName=="")ShowMessage("未安装打印机!");
- else ShowMessage(PrinterName);
- //
- rg->CloseKey();
- rg->Free();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- AnsiString ass;
- TRegistry *rg;
- rg=new TRegistry();
- rg->RootKey=HKEY_LOCAL_MACHINE;
- //
- Memo1->Clear();
- rg->OpenKey("\Config\0001\Display\Settings",False);
- ass=rg->ReadString("BitsPerPixel");
- Memo1->Lines->Add("颜色(每像素点的位数):"+ass);
- ass=rg->ReadString("Resolution");
- Memo1->Lines->Add("屏幕区域(横向像素、纵向像素):"+ass);
- ass=rg->ReadString("DPILogicalX");
- Memo1->Lines->Add("横向逻辑分辨率:"+ass);
- ass=rg->ReadString("DPILogicalY");
- Memo1->Lines->Add("纵向逻辑分辨率:"+ass);
- ass=rg->ReadString("DPIPhysicalX");
- Memo1->Lines->Add("横向物理分辨率:"+ass);
- ass=rg->ReadString("DPIPhysicalY");
- Memo1->Lines->Add("纵向物理分辨率:"+ass);
- //
- rg->CloseKey();
- rg->Free();
- }
- //---------------------------------------------------------------------------