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.   MonthCalendar1->Date=Now();
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TForm1::Button1Click(TObject *Sender)
  18. {
  19.   TRegistry *rg;
  20.   AnsiString ass;
  21.   ass=GetCurrentDir();
  22.   ass=ass+"\"+ExtractFileName(Application->ExeName);
  23.   rg=new TRegistry();
  24.   rg->RootKey=HKEY_LOCAL_MACHINE;
  25.   rg->OpenKey("\Software\Microsoft\Windows\CurrentVersion\Run",True);
  26.   rg->WriteString("MyCalendar",ass);
  27.   rg->CloseKey();
  28.   rg->Free();
  29. }
  30. //---------------------------------------------------------------------------
  31. void __fastcall TForm1::Button2Click(TObject *Sender)
  32. {
  33.   TRegistry *rg;
  34.   rg=new TRegistry();
  35.   rg->RootKey=HKEY_LOCAL_MACHINE;
  36.   rg->OpenKey("\Software\Microsoft\Windows\CurrentVersion\Run",True);
  37.   rg->DeleteValue("MyCalendar");
  38.   rg->CloseKey();
  39.   rg->Free();
  40. }
  41. //---------------------------------------------------------------------------
  42. void __fastcall TForm1::Button3Click(TObject *Sender)
  43. {
  44.   Close();        
  45. }
  46. //---------------------------------------------------------------------------