config.cpp
上传用户:deyixm
上传日期:2007-01-06
资源大小:43k
文件大小:5k
源码类别:

行业应用

开发平台:

Visual C++

  1. //---------------------------------------------------------------------------
  2. // 学韬电子光盘册   版本: 1.0.2
  3. // 作者:颜承     时间:2000.1.17
  4. // 主要构件: TListView ,TTreeView ,TClientDataSet ,TList,TMemIniFile等
  5. // API函数: GetVolumeInformation,ShellExecute  GetDriveType GetLogicDriveStrings
  6. // 自定义类: TSerchDisk 递归方法搜索整个磁盘目录文件结构
  7. // 此为设置窗口实现文件
  8. //---------------------------------------------------------------------------
  9. // 版权所有(C)2000 颜 承
  10. // 这一程序是自由软件,
  11. // 你可以遵照自由软件基金会出版的GNU通用公共许可证条款来修改和重新发布这一程序。
  12. // 发布这一程序的目的是希望它有用,但没有任何担保。甚至没有适合特定目的的隐含的担保。
  13. // 更详细的情况请参阅GNU通用公共许可证。
  14. // 你应该已经和程序一起收到一份GNU通用公共许可证的副本。
  15. // 我的联系方式:桂林集琦药业股份有限公司技术部(541004)
  16. // E-Mail: ycshowtop@sohu.com
  17. //-------------------------------------------------------------------------------
  18. #include <vcl.h>
  19. #include <vcl/registry.hpp>
  20. #pragma hdrstop
  21. #include "config.h"
  22. //---------------------------------------------------------------------------
  23. #pragma package(smart_init)
  24. #pragma resource "*.dfm"
  25. TForm6 *Form6;
  26. //---------------------------------------------------------------------------
  27. __fastcall TForm6::TForm6(TComponent* Owner)
  28.         : TForm(Owner)
  29. {
  30. }
  31. //---------------------------------------------------------------------------
  32. void __fastcall TForm6::btOkClick(TObject *Sender)
  33. {
  34.  AnsiString temp,tmp;
  35.  int iCount,i;
  36.  temp=ExtractFileDir(Application->ExeName);
  37.  temp=temp+AnsiString("\cdpack.ini");
  38.  TMemIniFile * Reg=new TMemIniFile(temp);
  39.  Reg->Clear();
  40.  iCount=ListBox1->Items->Count;
  41.  Reg->WriteInteger("Common","FilterCount",iCount);
  42.  Reg->WriteBool("Common","FileBind",cbBind->Checked);
  43.  Reg->WriteBool("Common","HtmlLink",cbLink->Checked);
  44.  for(i=0;i<iCount;i++) {
  45.    tmp=AnsiString("item")+AnsiString(i);
  46.    Reg->WriteString("Filter",tmp,ListBox1->Items->Strings[i]);
  47.  }
  48.  Reg->UpdateFile();
  49.  delete Reg;
  50.  TRegIniFile * Reg1 = new TRegIniFile("");
  51.  Reg1->RootKey=HKEY_CLASSES_ROOT;
  52.  if(cbBind->Checked==true) {
  53.     temp=Application->ExeName;
  54.     Reg1->CreateKey(".cdb");
  55.     Reg1->WriteString(".cdb","","光盘册文件");
  56.     Reg1->CreateKey("光盘册文件\DefaultIcon");
  57.     Reg1->CreateKey("光盘册文件\Shell\open\command");
  58.     Reg1->WriteString("光盘册文件\Shell\open\command","",temp+AnsiString(" %1"));
  59.     Reg1->WriteString("光盘册文件\DefaultIcon","",temp+AnsiString(" ,1"));
  60.  }
  61.  else {
  62.     Reg1->EraseSection(".cdb");
  63.     Reg1->EraseSection("光盘册文件");
  64.  }
  65.  delete Reg1;
  66.  Close();
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TForm6::FormCreate(TObject *Sender)
  70. {
  71.  AnsiString tmp;
  72.  int iCount,i;
  73.  tmp=ExtractFileDir(Application->ExeName);
  74.  tmp=tmp+AnsiString("\cdpack.ini");
  75.  TMemIniFile * Reg=new TMemIniFile(tmp);
  76.  if(Reg->SectionExists("Common") && Reg->SectionExists("Filter")) {
  77.     if(Reg->ValueExists("Common","FileBind"))
  78.        cbBind->Checked=Reg->ReadBool("Common","FileBind",false);
  79.     if(Reg->ValueExists("Common","HtmlLink"))
  80.        cbLink->Checked=Reg->ReadBool("Common","HtmlLink",false);
  81.     if(Reg->ValueExists("Common","FilterCount"))
  82.       iCount = Reg->ReadInteger("Common","FilterCount",3);
  83.       ListBox1->Clear();
  84.       for(i=0;i<iCount;i++) {
  85.         tmp=AnsiString("item")+AnsiString(i);
  86.         if(Reg->ValueExists("Filter",tmp))
  87.            ListBox1->Items->Add(Reg->ReadString("Filter",tmp,""));
  88.       }
  89.       ListBox1->ItemIndex=0;
  90.  }
  91.  else  Application->MessageBox("错误的ini文件!","错误",MB_OK);
  92.  delete Reg;
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TForm6::Edit1Change(TObject *Sender)
  96. {
  97.  if(Edit1->Text!="")btAdd->Enabled=true;
  98.  else btAdd->Enabled=false;
  99. }
  100. //---------------------------------------------------------------------------
  101. void __fastcall TForm6::btAddClick(TObject *Sender)
  102. {
  103.  if(ListBox1->Items->Count < 16)
  104.     ListBox1->Items->Add(Edit1->Text);
  105.  else Application->MessageBox("搜索文件类型不能超过16个!","提示",MB_OK);
  106. }
  107. //---------------------------------------------------------------------------
  108. void __fastcall TForm6::btDelClick(TObject *Sender)
  109. {
  110.  ListBox1->Items->Delete(ListBox1->ItemIndex);
  111. }
  112. //---------------------------------------------------------------------------
  113. void __fastcall TForm6::btCancelClick(TObject *Sender)
  114. {
  115.  Close();        
  116. }
  117. //---------------------------------------------------------------------------