[译]建立CD目录数据库
By robot-v1.0
本文链接 https://www.kyfws.com/applications/build-a-cd-directory-database-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 3 分钟阅读 - 1274 个词 阅读量 0[译]建立CD目录数据库
原文地址:https://www.codeproject.com/Articles/5143/Build-a-CD-directory-database
原文作者:Jack Janssen
译文由本站 robot-v1.0 翻译
前言
An article on a tool for making a database containing the directories of CDs etc.
有关用于制作包含CD等目录的数据库的工具的文章.
介绍(Introduction)
不久前,我想熟悉Win32 API.因此,我需要构建一些东西,使我有机会使用各种控件和内置函数.我决定制作一个程序来查看任何HD或CD的目录结构,可以在其中添加我自己的注释,并可以选择将该信息保存在文件中.我还添加了搜索功能.由于我经常使用CodeProject中的信息来解决遇到的特定问题,因此与大家分享结果似乎是一个好主意.(A little while ago I wanted to get acquainted with the Win32 API. So I needed to build something that would give me the opportunity to use all kinds of controls and built-in functions. I decided on making a program to view the directory structure of any HD or CD, to which I could add my own remarks and having the option to save that information in a file. I also added a search function. Since I often used information in CodeProject to solve particular problems I encountered, it looked like a good idea to share the result with you guys.)
使用代码(Using the code)
我认为使用该程序非常简单.有关详细信息,请参阅演示中包含的帮助文件.总结其功能:(Using the program is quite straight forward I think. For details please refer to the help file included in the demo. To summarize its features:)
- 从任何CD或HD创建目录树;(Create directory trees from any CD or HD;)
- 将您自己的注释添加到树中的任何目录或文件中;(Add your own remarks to any directory or file in the tree;)
- 将结果保存在文件中;(Save the results in a file;)
- 在目录树或备注中搜索特定的字符串;(Search for a specific string in the directory tree or the remarks;)
- 打印树,包括备注.(Print the tree, including the remarks.) 我不想详述我构建的代码.我想这都是直接使用API.我更喜欢使用这些页面中描述的消息破解宏,例如Hernándi Pietro.它使您可以将大型回调函数分解为美观的紧凑代码段,如下所示:(I don’t want to elaborate on the code I built. I guess it’s all straight forward API usage. I preferred using the message cracking macro’s like Hernán di Pietro described in these pages. It allows you to break up the large callback functions into nicely looking compact pieces of code like these:)
BOOL CALLBACK NewDlgProc(HWND hwnd, UINT Message,
WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
HANDLE_MSG (hwnd, WM_INITDIALOG, NewDlgProc_OnInitDialog);
HANDLE_MSG (hwnd, WM_COMMAND, NewDlgProc_OnCommand);
case WM_CLOSE:
EndDialog(hwnd,0);
break;
default:
return FALSE;
}
return TRUE;
}
和:(and:)
void NewDlgProc_OnCommand(HWND hwnd, int id,
HWND hwndCtl, UINT codeNotify)
{
switch(id)
{
case ID_DIRNAME:
{
if(codeNotify == EN_UPDATE)
{
HWND hOkButton = GetDlgItem(hwnd, ID_POK);
BOOL x = EnableWindow(hOkButton, TRUE);
}
}
break;
case ID_DRIVE:
NewDlgProc_OnDrive(hwnd, id, hwndCtl, codeNotify);
break;
case ID_DIRLIST:
NewDlgProc_OnDirlist(hwnd, id, hwndCtl, codeNotify);
break;
case ID_SELDRIVE:
NewDlgProc_OnSeldrive(hwnd, id, hwndCtl, codeNotify);
break;
case ID_POPEN:
NewDlgProc_OnOpen(hwnd, id, hwndCtl, codeNotify);
break;
case ID_POK:
NewDlgProc_OnOk(hwnd, id, hwndCtl, codeNotify);
break;
case ID_PCANCEL:
if (!DestroyWindow(hwnd))
MessageBox(NULL, "Window Destruction Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
break;
}
}
对于其他新手,我可以通过以下方式推荐该教程(To other novices I can recommend the tutorial by) 布鲁克`迈尔斯(Brook Miles) .我发现了(. I found the) lcc编译器(lcc compiler) 有用.它具有很好的Win32支持,并包含各种模板.(useful. It has nice Win32 support and contains all kinds of templates.)
兴趣点(Points of interest)
我在(I encountered one peculiar problem in the) GetSaveFileName
功能.该功能失败,直到我设置了(function. The function failed until I set the) lpstrDefExt
成员(member in the) OPENFILENAME
大写字母的结构.在此之前,它什么也没做,甚至没有产生错误返回值.(structure in upper case characters. Before that it didn’t do anything, not even produce an error return value.)
历史(History)
- 这是第一个版本,日期为2003年10月2日(This is the first version, date Oct 2, 2003)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
VC7.0 VC7.1 C++ VC6 Windows Win2K Visual-Studio Dev 新闻 翻译