📄 cdfind.cpp
字号:
//---------------------------------------------------------------------------
// 学韬电子光盘册 版本: 1.2.1
// 作者:颜承 时间:2000.1.17
// 主要构件: TListView ,TTreeView ,TClientDataSet ,TList等
// API函数: GetVolumeInformation,ShellExecute,GetDriveType,GetLogicDriveStrings
// 自定义类: TSerchDisk 递归方法搜索整个磁盘目录文件结构
// 此为检索光盘实现文件
//---------------------------------------------------------------------------
// 版权所有(C)2000 颜 承
// 这一程序是自由软件,
// 你可以遵照自由软件基金会出版的GNU通用公共许可证条款来修改和重新发布这一程序。
// 发布这一程序的目的是希望它有用,但没有任何担保。甚至没有适合特定目的的隐含的担保。
// 更详细的情况请参阅GNU通用公共许可证。
// 你应该已经和程序一起收到一份GNU通用公共许可证的副本。
// 我的联系方式:桂林集琦药业股份有限公司技术部(541004)
// E-Mail: ycshowtop@sohu.com
//-------------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "CDFind.h"
#include "CDAdd.h"
#include "main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm5 *Form5;
//---------------------------------------------------------------------------
__fastcall TForm5::TForm5(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
//检索
void __fastcall TForm5::Button1Click(TObject *Sender)
{
unsigned long RetVal,a,b;
char str1[256],str2[156];
int i;
AnsiString TheCD;
for(i=0;i<256;i++) { str1[i]='\0'; str2[i]='\0';}
TheCD="";
AnsiString strDir= AnsiString(DriveComboBox1->Drive)+AnsiString(":\\");
//取光盘序列号
GetVolumeInformation(strDir.c_str(), str1,256,&RetVal,&a,&b,str2,256);
if(RetVal==0) { //没放入光盘 RetVal==0
Application->MessageBox("未能检测到光盘!","提示",MB_OK);
return;
}
else TheCD=AnsiString(RetVal);
TLocateOptions op;
op.Clear();
op<<loCaseInsensitive;
//查找此光盘的记录
Form1->ClientDataSet1->First();
bool Isfind = Form1->ClientDataSet1->Locate("CDSeriNo",TheCD,op); //定位在此光盘的记录上
if(Isfind==false){
int res = MessageDlg("光盘库中没有这张光盘的记录!是否新建光盘记录?",mtWarning,TMsgDlgButtons()<<mbYes<<mbNo,0);
if(res==mrYes) {
Form3->DriveComboBox1->Drive=DriveComboBox1->Drive; //新建光盘记录
Form3->Show();
}
Close();
}
//检索到此光盘,在TreeView定位此光盘项目上
TTreeNode * myNode=Form1->TreeView1->Items->Item[1];
while(myNode!=NULL) {
if(myNode->Text==Form1->ClientDataSet1->FieldValues["CDName"]) break;
myNode=myNode->GetNext();
}
if(myNode!=NULL) Form1->TreeView1->Selected=myNode;
Close();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -