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

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::CDAutoPlay(bool bl)
  17. {
  18.   char ss[6];
  19.   TRegistry *rg;
  20. //
  21.   rg=new TRegistry();
  22.   rg->RootKey=HKEY_CURRENT_USER;
  23.   rg->OpenKey("\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer",False);
  24.   rg->ReadBinaryData("NoDriveTypeAutoRun",ss,4);
  25.   if(bl)ss[0]=0x95;
  26.   else  ss[0]=0xB5;
  27.   rg->WriteBinaryData("NoDriveTypeAutoRun",ss,4);
  28. //
  29.   rg->CloseKey();
  30.   rg->Free();
  31. }
  32. //---------------------------------------------------------------------------
  33. void __fastcall TForm1::Button1Click(TObject *Sender)
  34. {
  35.   CDAutoPlay(True);
  36. }
  37. //---------------------------------------------------------------------------
  38. void __fastcall TForm1::Button2Click(TObject *Sender)
  39. {
  40.   CDAutoPlay(False);
  41. }
  42. //---------------------------------------------------------------------------