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 DstPath;
  19.   TRegistry *rg;
  20. //
  21.   DstPath="C:\Tagboy";
  22.   rg=new TRegistry();
  23.   rg->RootKey=HKEY_LOCAL_MACHINE;
  24. //图标部分
  25.   rg->OpenKey("\Software\CLASSES\.TAG",True);
  26.   rg->WriteString("","Wang_Xiao_Hua.TagBoy");
  27.   rg->OpenKey("\Software\CLASSES\Wang_Xiao_Hua.TagBoy\DefaultIcon",True);
  28.   rg->WriteString("",DstPath+"\TagBoy.exe");
  29.   rg->OpenKey("\Software\CLASSES\Wang_Xiao_Hua.TagBoy\Shell\open\command",True);
  30.   rg->WriteString("",DstPath+"\TagBoy.exe "%1"");
  31.   rg->CloseKey();
  32.   rg->Free();
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall TForm1::Button2Click(TObject *Sender)
  36. {
  37.   AnsiString ass;
  38.   TRegistry *rg;
  39. //
  40.   ass=Edit1->Text.Trim();
  41.   rg=new TRegistry();
  42.   rg->RootKey=HKEY_LOCAL_MACHINE;
  43. //图标部分
  44.   rg->OpenKey("\Software\CLASSES\"+ass,False);
  45.   ass=rg->ReadString("");
  46.   rg->OpenKey("\Software\CLASSES\"+ass+"\DefaultIcon",False);
  47.   ass=rg->ReadString("");
  48.   rg->CloseKey();
  49.   rg->Free();
  50.   ShowMessage(ass);
  51. }
  52. //---------------------------------------------------------------------------