2023年全國碩士研究生考試考研英語一試題真題(含答案詳解+作文范文)_第1頁
已閱讀1頁,還剩13頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、<p><b>  附錄</b></p><p>  附錄A 外文翻譯-原文部分</p><p>  Computer programming data structure is an important theoretical basis for the design, it is not only the core curriculum of compu

2、ter disciplines, and has become a popular elective course other Polytechnic professional, so studied this course well and studied computer are closely related.</p><p>  一、the concept of data structure</p&

3、gt;<p>  Computer data structure is the foundation of science and technology professional classes, is the essential core curriculum. All computer system software and application software to use various types of da

4、ta structures. Therefore, if we want to make better use of computers to solve practical problems, only to several computer programming languages are difficult to cope with the many complex issues. To the effective use of

5、 computers, give full play to computer performance, but also must learn and </p><p>  二、why should learn from data structure?</p><p>  In the early development of computers, the use of computer

6、designed primarily to deal with terms. When we use the computer to solve a specific problem, the following general needs through several steps : the first is a specific problem of appropriate abstract mathematical models

7、, and then design or choose a mathematical model of the algorithm,the final procedures for debugging, testing, until they have the ultimate answer. </p><p>  Since then the object is INTEGER, REAL, BOOLEAN

8、, the procedures of the main designers of energy is focused on programming skills, without attention to the data structure. With the expansion of computer applications and development of software and hardware, the issue

9、of non-terms increasing importance. According to statistics, Now dealing with the issue of non-occupancy of more than 90% of the machine time. Such issues involve more complex data structure, the relationships between da

10、ta elements g</p><p>  Description of the terms of such non-mathematical model is not a mathematical equation, but such as tables, trees, such as map data structure. Therefore, it can be said that data struc

11、ture courses primarily designed to study the issue of non-value calculation procedures as a computer operations and the relationship between objects and their operating disciplines. </p><p>  The purpose of

12、the study is to understand the structure of data for computer processing of the identity object to the practical problems involved in dealing with that subject at the computer out and deal with them. At the same time, th

13、rough training algorithms to improve the thinking ability of students through procedures designed to promote student skills integrated applications and professional qualities.</p><p>  三、the concepts and ter

14、minology</p><p>  Systematic study of knowledge in the data structure before some of the basic concepts and terminology to give a precise meaning. </p><p>  Data (Data) is the information carr

15、ier, it could be computer identification, storage and processing. It is the computer processing of raw materials, a variety of data processing applications. Computer science, computer processing is the so-called data obj

16、ects, which can be numerical data can be non - numerical data. Numerical data are integer, the actual number or plural, mainly for engineering computing, scientific computing and commercial processing; Non - numerical da

17、ta, including characters,</p><p>  Data elements (Data Element) is the basic unit of data. In different conditions, data elements can be called elements, nodes, the peak, recording. For example, students inf

18、ormation retrieval system table information, a record high, 8 Queen's issue of a state tree, teaching programming issues such as a peak, known as a data element. Sometimes, a data from a number of data elements (Da

19、ta Item), for example, the student information management system students each data element table is a student r</p><p>  Data objects (Data Object) or data element type (Data Element Class) is the nature of

20、 the data elements with the same pool. In a specific issue, the data elements have the same nature (not necessarily equal value elements), belonging to the same data objects (data element type), the data element is an ex

21、ample of such data elements. For example, traffic information systems in the transportation network, is a culmination of all the data elements category, peak a and B each represent an urban middl</p><p>  Da

22、ta structure (Data Structure) refers to the mutual relationship that exists between one or more data elements together. In any case, between data elements will not be isolated in between them exist in one way or another,

23、 such as the relationship between the data element structure. According to the data elements of the relationship between different characteristics, usually have the following four basic categories of the structure : &l

24、t;/p><p>  1 assembly structures. In the assembly structure, the relationship between data elements is "belonging to the same pool." Assembly elements relations is a very loose structure. </p>

25、<p>  2 linear structures. The structure of the data elements exist between one-to-one relationship. </p><p>  3 tree structure. The structure of the data elements exist between hierarchical relatio

26、nship. </p><p>  4graphics structure. The structure of the data elements of the relationship that existed between Duoduiduo, graphics structure also known as network structure.</p><p>  C++Bui

27、lder programming experience</p><p>  一、Database programming</p><p>  And the use of Delphi, Borland C++Builder BDE (Borland Database Engine) database interface, in particular its use BDE Admin

28、istrator unified management database alias, the database operation has nothing to do with the location of the database documents, thus enabling database development easier operation. But in a database application procedu

29、res at the same time we have to "release" BDE, the database for some simple procedures may BDE than our own design procedures big, but as the use of BDE In</p><p>  Thus, no impact on the debugging

30、 phase, will be issued if the application procedures Table1 document on the use of databases or their current catalogue "DB" virus, database procedures can be normal operation. You can even be a database to cat

31、alogue the documents in the form of character string Register (installed in the installation process), then the procedure in the acquisition of substantially from the catalogue of payrolls, Fuzhi DatabaseName attribute t

32、o be. Anyway, you do not need to insta</p><p>  二、the Registry visit</p><p>  As in the design process we often required 9x/NT Windows Registry information visit, such as retrieval of informati

33、on procedures, preservation of information. Register write a subroutine to visit necessary. When the Register to visit, the library will be directly available without always some duplication operation. The following can

34、be used to access cosmetic Licheng, the character string type Jianzhi, and the retrieval of failure to return default value Default.</p><p>  #include < Registry.hpp ></p><p>  int ReadInt

35、FromReg(HKEY Root, AnsiString Key,</p><p>  AnsiString KeyName, int Default) {</p><p>  int KeyValue;</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry-

36、>RootKey = Root;</p><p>  Registry->OpenKey(Key, false);</p><p><b>  try {</b></p><p>  KeyValue = Registry->ReadInteger(KeyName);</p><p><b>

37、  }</b></p><p>  catch(...) {</p><p>  KeyValue = Default;</p><p><b>  }</b></p><p>  delete Registry;</p><p>  return KeyValue;</p>

38、;<p><b>  }</b></p><p>  void SaveIntToReg(HKEY Root, AnsiString Key,</p><p>  AnsiString KeyName, int KeyValue) {</p><p>  TRegistry *Registry = new TRegistry();

39、</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, true);</p><p>  Registry->WriteInteger(KeyName, KeyValue);</p><p>  delete Registry;</p&

40、gt;<p><b>  }</b></p><p>  char *ReadStringFromReg(HKEY Root, AnsiString Key,</p><p>  AnsiString KeyName, char *Default) {</p><p>  AnsiString KeyValue;</p>

41、;<p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, false);</p><p><b>  try {</b></p>&l

42、t;p>  KeyValue = Registry->ReadString(KeyName);</p><p><b>  }</b></p><p>  catch(...) {</p><p>  KeyValue = (AnsiString)Default;</p><p><b>  }&l

43、t;/b></p><p>  delete Registry;</p><p>  return KeyValue.c_str();</p><p><b>  }</b></p><p>  void SaveStringToReg(HKEY Root, AnsiString Key, </p>

44、<p>  AnsiString KeyName, char *KeyValue) {</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, true);</

45、p><p>  Registry->WriteString(KeyName, (AnsiString)KeyValue);</p><p>  delete Registry;</p><p><b>  } </b></p><p>  We may use the following access methods

46、(to Windows wallpaper documents) :</p><p>  AnsiString WallPaperFileName = </p><p>  ReadStringFromReg(HKEY_CURRENT_USER,</p><p>  "\\Control Panel\\Desktop", "Wallpa

47、per", "");</p><p>  三、show / hide icons task column </p><p>  Standard Windows applications generally operating in the mission mandate column on the chart shows, users can direct

48、ly use the mouse clicking column logo for the mission task cut over, but some applications do not use task column signs, such as the typical Office tools, There are also procedures that can be shown or hidden customizati

49、on tasks column icon, such as Winamp. We can do the procedure, as long as access Windows SetWindowLong function can drive, as follows : </p><p>  // hidden task column chart : </p><p>  Se

50、tWindowLong (Application->Handle. </p><p>  GWL_EXSTYLE, WS_EX_TOOLWINDOW); </p><p>  // task column shows signs : </p><p>  SetWindowLong (Application->Handle. </p

51、><p>  GWL_EXSTYLE, WS_EX_APPWINDOW);</p><p>  四、the establishment of a simple "on" window</p><p>  A complete Windows applications typically contain a "on the" win

52、dow to show version information. We customized a dialog box as usual "on the" window of the "on" free customized window, indicates that more information, even including super links. If only show simpl

53、e version information, </p><p>  Windows ShellAbout function shelf items have sufficient, following this line of code can be "on" Duihuakuang and is Windows standard "on the" Duihuakuang

54、and procedures may show signs such as the use of resources and systems. </p><p>  ShellAbout (Handle, ( "on" +Application->Title+ "#"). C_str () ( "\n" +Application->T

55、itle+ "V1.0\n\n" + "夏登城 版權(quán)所有!"). C_str () Application->Icon->Handle);</p><p>  五、the two methods to choice catalogue</p><p>  In our applications, allowing users to c

56、hoose the regular catalogue, such as software manufacturers, users choose catalogue. This involves catalogue option, we may use the following methods for users to choose one of the catalogue : </p><p>  1,

57、 use SHBrowseForFolder and SHGetPathFromIDList function; Company affirms its function as follows : </p><p>  WINSHELLAPI LPITEMIDLIST WINAPI SHBrowseForFolder(LPBROWSEINFO lpbi); WINSHELLAPI BOOL WINAPI SH

58、GetPathFromIDList(LPCITEMIDLIST pidl, LPSTR pszPath); LPBROWSEINFO和LPITEMIDLIST structure refer Win32 files. This method of selecting catalogues available Windows desktop all available inventory, including networks of ot

59、her computers sharing catalogue neighbors, but not the new catalogue. Li Cheng allows users to choose the following directory, the directory of choice Licheng return at all trails char</p><p>  #include <

60、 shlobj.h ></p><p>  char *GetDir(char *DisplayName, HWND Owner) {</p><p>  char dir[MAX_PATH] = "";</p><p>  BROWSEINFO *bi = new BROWSEINFO;</p><p>  bi-

61、>hwndOwner = Owner;</p><p>  bi->pidlRoot = NULL;</p><p>  bi->pszDisplayName = NULL;</p><p>  bi->lpszTitle = DisplayName;</p><p>  bi->ulFlags = BIF_RE

62、TURNONLYFSDIRS;</p><p>  bi->lpfn = NULL;</p><p>  bi->lParam = NULL;</p><p>  bi->iImage = 0;</p><p>  ITEMIDLIST *il = SHBrowseForFolder(bi);</p><

63、p>  if(il!=NULL) {</p><p>  SHGetPathFromIDList(il, dir);</p><p><b>  }</b></p><p>  delete bi;</p><p>  return dir;</p><p><b>  }<

64、/b></p><p>  We can use the following list to be chosen from : </p><p>  AnsiString at Dir = (AnsiString) GetDir ( "Please select catalogue :" Handle);</p><p>  2, the

65、 use of SelectDirectory function. C++Builder the function SelectDirectory achievable catalogue of options, which showed that similar "open" / "preserve" Duihuakuang, but its advantage is to use / non-

66、use keyboard input catalogue members, and allow the creation of new directories. Its original definition as follows : </p><p>  Extern package bool __fastcall SelectDirectory ( AnsiString &Directory,

67、 TSelectDirOpts Options, 103-116 HelpCtx); </p><p>  Licheng SelectDir allow you to choose the following directory : </p><p>  #include < FileCtrl.hpp ></p><p>  AnsiStri

68、ng SelectDir(AnsiString Dir) {</p><p>  if(SelectDirectory(Dir, TSelectDirOpts()</p><p>  << sdAllowCreate << sdPerformCreate << sdPrompt,0))</p><p>  return Dir;&

69、lt;/p><p><b>  else</b></p><p>  return "";</p><p><b>  }</b></p><p>  for the following redeployed to the users choice catalogue : <

70、;/p><p>  AnsiString SelectedDir = SelectDir ( "C:\\My Documents");</p><p>  附錄B 外文翻譯-譯文部分</p><p>  數(shù)據(jù)結(jié)構(gòu)是計(jì)算機(jī)程序設(shè)計(jì)的重要理論設(shè)計(jì)基礎(chǔ),它不僅是計(jì)算機(jī)學(xué)科的核心課程,而且已成為其他理工專業(yè)的熱門選修課,所以學(xué)好這門課程是與學(xué)好計(jì)算機(jī)專業(yè)是息

71、息相關(guān)的。</p><p><b>  一,數(shù)據(jù)結(jié)構(gòu)的概念</b></p><p>  數(shù)據(jù)結(jié)構(gòu)是計(jì)算機(jī)科學(xué)與技術(shù)專業(yè)的專業(yè)基礎(chǔ)課,是十分重要的核心課程。所有的計(jì)算機(jī)系統(tǒng)軟件和應(yīng)用軟件都要用到各種類型的數(shù)據(jù)結(jié)構(gòu)。因此,要想更好地運(yùn)用計(jì)算機(jī)來解決實(shí)際問題,僅掌握幾種計(jì)算機(jī)程序設(shè)計(jì)語言是難以應(yīng)付眾多復(fù)雜的課題的。要想有效地使用計(jì)算機(jī)、充分發(fā)揮計(jì)算機(jī)的性能,還必須學(xué)習(xí)和掌握

72、好數(shù)據(jù)結(jié)構(gòu)的有關(guān)知識(shí)。打好“數(shù)據(jù)結(jié)構(gòu)”這門課程的扎實(shí)基礎(chǔ),對于學(xué)習(xí)計(jì)算機(jī)專業(yè)的其他課程,如操作系統(tǒng)、編譯原理、數(shù)據(jù)庫管理系統(tǒng)、軟件工程、人工智能等都是十分有益的。</p><p>  二,為什么要學(xué)習(xí)數(shù)據(jù)結(jié)構(gòu)</p><p>  在計(jì)算機(jī)發(fā)展的初期,人們使用計(jì)算機(jī)的目的主要是處理數(shù)值計(jì)算問題。當(dāng)我們使用計(jì)算機(jī)來解決一個(gè)具體問題時(shí),一般需要經(jīng)過下列幾個(gè)步驟:首先要從該具體問題抽象出一個(gè)適當(dāng)?shù)?/p>

73、數(shù)學(xué)模型,然后設(shè)計(jì)或選擇一個(gè)解此數(shù)學(xué)模型的算法,最后編出程序進(jìn)行調(diào)試、測試,直至得到最終的解答。例如,求解梁架結(jié)構(gòu)中應(yīng)力的數(shù)學(xué)模型的線性方程組,該方程組可以使用迭代算法來求解。</p><p>  由于當(dāng)時(shí)所涉及的運(yùn)算對象是簡單的整型、實(shí)型或布爾類型數(shù)據(jù),所以程序設(shè)計(jì)者的主要精力是集中于程序設(shè)計(jì)的技巧上,而無須重視數(shù)據(jù)結(jié)構(gòu)。隨著計(jì)算機(jī)應(yīng)用領(lǐng)域的擴(kuò)大和軟、硬件的發(fā)展,非數(shù)值計(jì)算問題越來越顯得重要。據(jù)統(tǒng)計(jì),當(dāng)今處理非

74、數(shù)值計(jì)算性問題占用了90%以上的機(jī)器時(shí)間。這類問題涉及到的數(shù)據(jù)結(jié)構(gòu)更為復(fù)雜,數(shù)據(jù)元素之間的相互關(guān)系一般無法用數(shù)學(xué)方程式加以描述。因此,解決這類問題的關(guān)鍵不再是數(shù)學(xué)分析和計(jì)算方法,而是要設(shè)計(jì)出合適的數(shù)據(jù)結(jié)構(gòu),才能有效地解決問題。</p><p>  描述這類非數(shù)值計(jì)算問題的數(shù)學(xué)模型不再是數(shù)學(xué)方程,而是諸如表、樹、圖之類的數(shù)據(jù)結(jié)構(gòu)。因此,可以說數(shù)據(jù)結(jié)構(gòu)課程主要是研究非數(shù)值計(jì)算的程序設(shè)計(jì)問題中所出現(xiàn)的計(jì)算機(jī)操作對象以及

75、它們之間的關(guān)系和操作的學(xué)科。</p><p>  學(xué)習(xí)數(shù)據(jù)結(jié)構(gòu)的目的是為了了解計(jì)算機(jī)處理對象的特性,將實(shí)際問題中所涉及的處理對象在計(jì)算機(jī)中表示出來并對它們進(jìn)行處理。與此同時(shí),通過算法訓(xùn)練來提高學(xué)生的思維能力,通過程序設(shè)計(jì)的技能訓(xùn)練來促進(jìn)學(xué)生的綜合應(yīng)用能力和專業(yè)素質(zhì)的提高。</p><p><b>  三,有關(guān)概念和術(shù)語</b></p><p>

76、  在系統(tǒng)地學(xué)習(xí)數(shù)據(jù)結(jié)構(gòu)知識(shí)之前,先對一些基本概念和術(shù)語賦予確切的含義。</p><p>  數(shù)據(jù)(Data)是信息的載體,它能夠被計(jì)算機(jī)識(shí)別、存儲(chǔ)和加工處理。它是計(jì)算機(jī)程序加工的原料,應(yīng)用程序處理各種各樣的數(shù)據(jù)。計(jì)算機(jī)科學(xué)中,所謂數(shù)據(jù)就是計(jì)算機(jī)加工處理的對象,它可以是數(shù)值數(shù)據(jù),也可以是非數(shù)值數(shù)據(jù)。數(shù)值數(shù)據(jù)是一些整數(shù)、實(shí)數(shù)或復(fù)數(shù),主要用于工程計(jì)算、科學(xué)計(jì)算和商務(wù)處理等;非數(shù)值數(shù)據(jù)包括字符、文字、圖形、圖像、語音等

77、。</p><p>  數(shù)據(jù)元素(Data Element)是數(shù)據(jù)的基本單位。在不同的條件下,數(shù)據(jù)元素又可稱為元素、結(jié)點(diǎn)、頂點(diǎn)、記錄等。例如,學(xué)生信息檢索系統(tǒng)中學(xué)生信息表中的一個(gè)記錄、八皇后問題中狀態(tài)樹的一個(gè)狀態(tài)、教學(xué)計(jì)劃編排問題中的一個(gè)頂點(diǎn)等,都被稱為一個(gè)數(shù)據(jù)元素。</p><p>  有時(shí),一個(gè)數(shù)據(jù)元素可由若干個(gè)數(shù)據(jù)項(xiàng)(Data Item)組成,例如,學(xué)籍管理系統(tǒng)中學(xué)生信息表的每一個(gè)數(shù)

78、據(jù)元素就是一個(gè)學(xué)生記錄。它包括學(xué)生的學(xué)號(hào)、姓名、性別、籍貫、出生年月、成績等數(shù)據(jù)項(xiàng)。這些數(shù)據(jù)項(xiàng)可以分為兩種:一種叫做初等項(xiàng),如學(xué)生的性別、籍貫等,這些數(shù)據(jù)項(xiàng)是在數(shù)據(jù)處理時(shí)不能再分割的最小單位;另一種叫做組合項(xiàng),如學(xué)生的成績,它可以再劃分為數(shù)學(xué)、物理、化學(xué)等更小的項(xiàng)。通常,在解決實(shí)際應(yīng)用問題時(shí)是把每個(gè)學(xué)生記錄當(dāng)作一個(gè)基本單位進(jìn)行訪問和處理的。</p><p>  數(shù)據(jù)對象(Data Object)或數(shù)據(jù)元素類(Da

79、ta Element Class)是具有相同性質(zhì)的數(shù)據(jù)元素的集合。在某個(gè)具體問題中,數(shù)據(jù)元素都具有相同的性質(zhì)(元素值不一定相等),屬于同一數(shù)據(jù)對象(數(shù)據(jù)元素類),數(shù)據(jù)元素是數(shù)據(jù)元素類的一個(gè)實(shí)例。例如,在交通咨詢系統(tǒng)的交通網(wǎng)中,所有的頂點(diǎn)是一個(gè)數(shù)據(jù)元素類,頂點(diǎn)A和頂點(diǎn)B各自代表一個(gè)城市,是該數(shù)據(jù)元素類中的兩個(gè)實(shí)例,其數(shù)據(jù)元素的值分別為A和B。</p><p>  數(shù)據(jù)結(jié)構(gòu)(Data Structure)是指互相之間

80、存在著一種或多種關(guān)系的數(shù)據(jù)元素的集合。在任何問題中,數(shù)據(jù)元素之間都不會(huì)是孤立的,在它們之間都存在著這樣或那樣的關(guān)系,這種數(shù)據(jù)元素之間的關(guān)系稱為結(jié)構(gòu)。根據(jù)數(shù)據(jù)元素間關(guān)系的不同特性,通常有下列四類基本的結(jié)構(gòu):</p><p> ?、偶辖Y(jié)構(gòu)。在集合結(jié)構(gòu)中,數(shù)據(jù)元素間的關(guān)系是“屬于同一個(gè)集合”。集合是元素關(guān)系極為松散的一種結(jié)構(gòu)。</p><p>  ⑵線性結(jié)構(gòu)。該結(jié)構(gòu)的數(shù)據(jù)元素之間存在著一對一的

81、關(guān)系。</p><p> ?、菢湫徒Y(jié)構(gòu)。該結(jié)構(gòu)的數(shù)據(jù)元素之間存在著一對多的關(guān)系。</p><p>  ⑷圖形結(jié)構(gòu)。該結(jié)構(gòu)的數(shù)據(jù)元素之間存在著多對多的關(guān)系,圖形結(jié)構(gòu)也稱作網(wǎng)狀結(jié)構(gòu)。</p><p>  C++Builder程序設(shè)計(jì)經(jīng)驗(yàn)</p><p><b>  數(shù)據(jù)庫程序設(shè)計(jì)</b></p><p&g

82、t;  Borland C++Builder與Delphi一樣使用BDE(Borland </p><p>  Database Engine)數(shù)據(jù)庫接口,特別是它使用BDE Administrator統(tǒng)一管理數(shù)據(jù)庫別名,使得數(shù)據(jù)庫操作與數(shù)據(jù)庫文件位置無關(guān),從而使數(shù)據(jù)庫開發(fā)更容易操作。但在發(fā)布應(yīng)用數(shù)據(jù)庫程序時(shí)我們不得不同時(shí)“發(fā)布”BDE,對于一些簡單的數(shù)據(jù)庫程序來說,可能BDE比我們的自己設(shè)計(jì)的程序還大,而且如使

83、用InstallShield配置BDE,添加數(shù)據(jù)庫別名,很可能會(huì)配置失敗。所以我們可以采用如下方法:在程序設(shè)計(jì)階段仍采用BDE管理數(shù)據(jù)庫別名進(jìn)行調(diào)試,但在程序初始化時(shí)(如在主窗體的OnCreate事件處理函數(shù)中)修改Table部件的DatabaseName屬性,如使用類似如下語句: </p><p>  Table1->DatabaseName = ExtractFilePath(Application-&

84、gt;ExeName);或 Table1->DatabaseName </p><p>  = ExtractFilePath(Application->ExeName+”DB”); </p><p>  這樣,對調(diào)試階段沒有什么影響,發(fā)布應(yīng)用程序時(shí)只要將Table1使用的數(shù)據(jù)庫文件放在當(dāng)前目錄或其“DB”子目錄下,數(shù)據(jù)庫程序即可正常運(yùn)行。甚至您還可以將數(shù)據(jù)庫文件所在目錄以字符

85、串形式寫入注冊表(可在安裝程序中設(shè)置),然后在程序初始化時(shí)從注冊表獲取目錄名,賦值給DatabaseName屬性即可。無論怎樣,您不必強(qiáng)迫用戶安裝相對龐大的BDE了。</p><p><b>  二、 注冊表存取 </b></p><p>  在我們在設(shè)計(jì)Windows 9x/NT程序時(shí)經(jīng)常需進(jìn)行注冊表信息的存取,如讀取程序配置信息、保存配置信息等。寫一個(gè)注冊表存取子

86、程序就很有必要。當(dāng)需存取注冊表時(shí),直接調(diào)用此子程序即可,而不必每次都重復(fù)一些操作。下面的例程可用來存取整型、字符串型鍵值,并可在讀取失敗時(shí)返回缺省值Default。 </p><p>  #include < Registry.hpp ></p><p>  int ReadIntFromReg(HKEY Root, AnsiString Key,</p><

87、;p>  AnsiString KeyName, int Default) {</p><p>  int KeyValue;</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Registr

88、y->OpenKey(Key, false);</p><p><b>  try {</b></p><p>  KeyValue = Registry->ReadInteger(KeyName);</p><p><b>  }</b></p><p>  catch(...) {&

89、lt;/p><p>  KeyValue = Default;</p><p><b>  }</b></p><p>  delete Registry;</p><p>  return KeyValue;</p><p><b>  }</b></p><

90、;p>  void SaveIntToReg(HKEY Root, AnsiString Key,</p><p>  AnsiString KeyName, int KeyValue) {</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Roo

91、t;</p><p>  Registry->OpenKey(Key, true);</p><p>  Registry->WriteInteger(KeyName, KeyValue);</p><p>  delete Registry;</p><p><b>  }</b></p>&

92、lt;p>  char *ReadStringFromReg(HKEY Root, AnsiString Key,</p><p>  AnsiString KeyName, char *Default) {</p><p>  AnsiString KeyValue;</p><p>  TRegistry *Registry = new TRegistry

93、();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, false);</p><p><b>  try {</b></p><p>  KeyValue = Registry->ReadString(KeyNa

94、me);</p><p><b>  }</b></p><p>  catch(...) {</p><p>  KeyValue = (AnsiString)Default;</p><p><b>  }</b></p><p>  delete Registry;&l

95、t;/p><p>  return KeyValue.c_str();</p><p><b>  }</b></p><p>  void SaveStringToReg(HKEY Root, AnsiString Key, </p><p>  AnsiString KeyName, char *KeyValue) {&

96、lt;/p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, true);</p><p>  Registry->WriteString(KeyNam

97、e, (AnsiString)KeyValue);</p><p>  delete Registry;</p><p><b>  } </b></p><p>  我們可使用如下調(diào)用方法(獲得Windows墻紙文件名): </p><p>  AnsiString WallPaperFileName = </p

98、><p>  ReadStringFromReg(HKEY_CURRENT_USER,</p><p>  "\\Control Panel\\Desktop", "Wallpaper", "");</p><p>  三、 顯示/隱藏任務(wù)欄圖標(biāo) </p><p>  標(biāo)準(zhǔn)的Window

99、s應(yīng)用程序運(yùn)行時(shí)一般都會(huì)在任務(wù)欄上顯示任務(wù)圖標(biāo),用戶可直接用鼠標(biāo)點(diǎn)擊任務(wù)欄圖標(biāo)進(jìn)行任務(wù)切換,但有些應(yīng)用程序不使用任務(wù)欄圖標(biāo),如典型的Office工具條,也有些程序可由用戶定制顯示方式顯示或隱藏任務(wù)欄圖標(biāo),如Winamp。我們的程序中也可以做到,只要調(diào)用Windows </p><p>  API函數(shù)SetWindowLong即可,如下: </p><p>  // 隱藏任務(wù)欄圖標(biāo):<

100、/p><p>  SetWindowLong(Application->Handle, </p><p>  GWL_EXSTYLE, WS_EX_TOOLWINDOW);</p><p>  // 顯示任務(wù)欄圖標(biāo):</p><p>  SetWindowLong(Application->Handle,</p><

101、;p>  GWL_EXSTYLE, WS_EX_APPWINDOW);</p><p>  四、 建立簡單的“關(guān)于”窗口 </p><p>  一個(gè)完整的Windows應(yīng)用程序一般都包含一個(gè)“關(guān)于”窗口,用以顯示版本信息等。通常我們是定制一個(gè)對話框作為“關(guān)于”窗口,當(dāng)然這樣的“關(guān)于”窗口可以自由定制,顯示更多信息,甚至可包括超鏈接。但如只需顯示簡單版本信息等,</p>

102、<p>  Windows Shell Library 函數(shù)ShellAbout已足夠了,下面這行代碼就可以顯示“關(guān)于”對話框,而且是Windows標(biāo)準(zhǔn)的“關(guān)于”對話框,同時(shí)可顯示程序圖標(biāo)和系統(tǒng)資源使用情況等。 </p><p>  ShellAbout(Handle, ("關(guān)于"+Application->Title+"#").c_str(),</p

103、><p>  ("\n"+Application->Title+" V1.0\n\n"+"夏登城 版權(quán)所有!").c_str(),</p><p>  Application->Icon->Handle);</p><p>  五、 選擇目錄的兩種方法 </p><p>

104、;  在我們的應(yīng)用程序中經(jīng)常需讓用戶選擇目錄,如殺毒軟件中用戶選擇處理目錄等。這就涉及目錄的選擇,我們可使用如下方法之一讓用戶選擇目錄: </p><p>  1、 使用SHBrowseForFolder和SHGetPathFromIDList函數(shù);其函數(shù)原形申明如下: </p><p>  WINSHELLAPI LPITEMIDLIST WINAPI SHBrowseForFolder

105、(LPBROWSEINFO lpbi); </p><p>  WINSHELLAPI BOOL WINAPI SHGetPathFromIDList(LPCITEMIDLIST pidl, LPSTR pszPath); LPBROWSEINFO和LPITEMIDLIST的結(jié)構(gòu)請參考Win32文檔。這種方法選取目錄可獲得Windows桌面下所有可用的目錄,包括網(wǎng)絡(luò)鄰居中其它計(jì)算機(jī)的共享目錄等,但不可新建目錄。下

106、面的例程可讓用戶選擇目錄,該例程返回指向所選擇目錄的全路徑字符串。 </p><p>  #include < shlobj.h ></p><p>  char *GetDir(char *DisplayName, HWND Owner) {</p><p>  char dir[MAX_PATH] = "";</p>

107、<p>  BROWSEINFO *bi = new BROWSEINFO;</p><p>  bi->hwndOwner = Owner;</p><p>  bi->pidlRoot = NULL;</p><p>  bi->pszDisplayName = NULL;</p><p>  bi->

108、lpszTitle = DisplayName;</p><p>  bi->ulFlags = BIF_RETURNONLYFSDIRS;</p><p>  bi->lpfn = NULL;</p><p>  bi->lParam = NULL;</p><p>  bi->iImage = 0;</p&g

109、t;<p>  ITEMIDLIST *il = SHBrowseForFolder(bi);</p><p>  if(il!=NULL) {</p><p>  SHGetPathFromIDList(il, dir);</p><p><b>  }</b></p><p>  delete bi;&

110、lt;/p><p>  return dir;</p><p><b>  }</b></p><p>  我們可作如下調(diào)用得到選擇的目錄名: </p><p>  AnsiString Dir = (AnsiString)GetDir("請選擇目錄:", Handle);</p><

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論