The ancestors' Delphi Basic Development Skills

zhaozj2021-02-08  213

The ancestors' Delphi Basic Development Skills: The Source of the Guest: Dafa Forum

◇ [Delphi] Network neighbor replication file Uses shellapi; copyfile (pchar ('newfile.txt'), pchar ('// computername / direction / targer.txt'), false); ◇ [Delphi] produces mouse drag effect Mousemove event, Dragover event, Enddrag event implementation, Label: Var XPanel, Ypanel, XLabel, Ylabel: Integer; xPanel: = x; Ypanel: = Y; PANEL DRAGOVER Event: XPanel: = X; YPANEL: = Y; Label Mousemove event: xlabel: = x; ylabel: = y; Label's enddrag event: label.left: = xPanel-xlabel; label.top: = YPANEL-YLabel; ◇ [Delphi] obtaining WINDOWS directory uses shellapi; var windir: array [0..255] of char; getwindowsdirectory (windir, sizeof (windir)); or read from the registry location: HKEY_LOCAL_MACHINE / Software / Microsoft / Windows / CurrentVersionSystemRoot key, Saix: c: / windows ◇ [Delphi] Pipeline VAR X, Y: Array [0..50] of integer; canvas.pen.color: = CLRED; canvas.pen.Style: = Psdash; form1.canvas.moveto (Trunc (x [i]), trunc (y [i])); Form1.canvas.Lineto (Trunc (x [j]), trunc (y [j])); ◇ [◇ Delphi] String list uses var tips: tstringlist; tips: = tstringlist.create; tips.loadfromfile ('filename.txt'); edit1.text: = tips [0]; tips.add ('last line addition string') Tips.insert (1, 'INSERT STRING AT NO 2 LIN e '); tips.savetofile (' newfile.txt '); tips.free; ◇ [DELPHI] clipboard simple operation richedit1.selectall; richedit1.copytoclipboard; richedit1.cuttoclipboard; edit1.pastefromclipboard; ◇ [DELPHI] About File Catalog CHDIR ('c: / abcdir'); go to the directory MKDir ('DIRNAME'); establish the directory RMDIR ('DIRNAME'); delete the directory getCurrentDir; // Take the current directory name, no '/' getdir (0 , s); // Take the working directory name S: = 'c: / abcdir'; deleetfile ('abc.txt'); // Delete file renamefile ('ild.txt', 'new.txt'); // Document Name of ExtractFileName (fileListBox1.FileName); // Take the file name extractfileext (filelistbox1.filename); // Take a file suffix ◇ [Delphi] Process file attribute Attr: =

Filegetttr (FileListBox1.FileName); if (attridadonly = fareadonly kil1 ... // read-only if (attr and fasysfile) = FasysFile Then ... // System IF (attr and faarchive) = Faarchive Then ... // Archive IF (attr and fahidden) = Fahidden Then ... // Hide ◇ [Delphi] Execute the program outfinxec // Call the executable file WINEXEC ('command.com / c copy *. * C: /', SW_Normal); winexec ( 'start abc.txt'); ShellExecute or ShellExecuteEx // startup file associated program function executefile (const filename, params, defaultDir: string; showCmd: integer): THandle; ExecuteFile ( 'C: / abc / a .txt ',' x.abc ',' c: / abc / ', 0); Executefile (' http: //tingweb.yeah.net', '' ,'',0); Executefile (' Mailto: TingWeb @ wx88.net ',' ',' ', 0); ◇ [Delphi] gets the system running process name var hcurrentwindow: hwnd; sztext: array [0..254] of char; beginhcurrentWindow: = getWindow (Handle, gw_hwndfrist ); while hCurrentWindow <> 0 dobeginif Getwindowtext (hcurrnetwindow, @ sztext, 255)> 0 then listbox1.items.add (strpas (@sztext)); hCurrentWindow: = Getwindow (hCurrentwindow, GW_HWndNext); end; end; ◇ [DELPHI An EX, ECX, EBP, ESI, EDI, ESP, EBP, EBX can be modified arbitrarily modified ESI, EDI, ESP, EBP, EBX. ◇ [Delphi] About Type Conversion Function FLOATTOSTR / / Floating Stroke FloatTostrf // Floating Stroke InttoHex // Integer Transfer 16 Enter TimetostrDateTrDateTiMetostrfMTSTRDATSTRDATSTRFMTSTRDATSTRDATSTRDTSTRDATSTRFMTSTR / / Output String FormatDateTime ('YYYY-MM) -DD, HH-MM-SS ', date); ◇ [Delphi] String process and function INSERT (OBJ, Target, POS); // String Target is inserted in POS. If the insertion result is greater than the maximum length of Target, multiple characters will be cut off. Such as POS is 255, it will generate an error. For example, st: = 'brian', INSERT ('OK', ST, 2) will make ST to 'Brokian'. Delete (ST, POS, NUM); // From the POS (integer) position in the ST string, the number of substrings of NUM (integer) characters are started. For example, st: = 'brian', the delete (ST, 3, 2) will become BRN. Str (Value, ST); // Convert value value (integer or real) into a string in ST.

For example, when A = 2.5E4, the STR (A: 10, ST) will make the value of the ST '25000'. VAL (ST, VAR, CODE); // converts string expressions to a corresponding integer or real value, stored in VAR. St must be a string representing a value and complies with the rules of the numerical constant. During the conversion process, if an error is not detected, the variable code is set to 0, otherwise it is positioned as the first error character. For example, st: = 25.4e3, X is a real variable, the VAL (ST, X, CODE) will make the X value of 25400, the Code value is 0. Copy (st.pos.num); // Returns a substring containing Num (integer) characters at a position POS (integer) in the ST string. If the POS is greater than the length of the ST string, it will return an empty string. If POS is outside 255, it will cause an error. For example, st: = 'brian', then COPY (ST, 2, 2) returns 'ri'. Concat (ST1, ST2, ST3 ..., STN); // Connect all the strings indicated by all the variables, and returns the connected value. If the length 255 of the result will generate an operation error. For example, St1: = 'brian', ST2: = '', ST3: = 'WILFRED', then CONCAT (ST1, ST2, ST3) returns 'Brian Wilfred'. Length (ST); // Returns the length of the string expression ST. For example, St: = 'brian', the longth (ST) returns 5. POS (OBJ, TARGET); // Returns the first appearance of the string OBJ at the target string Target, if the target does not match the string, the return value of the POS function is 0. For example, Target: = 'Brian Wilfred', the return value of POS ('WIL', TARGET) is 7, and the return value of POS ('Hubet', Target) is 0.

◇ [Delphi] About Processing Registry Uses Registry; Var REG: Tregistry; Reg: = Tregistry.create; REG.ROOTKEY: = 'HKEY_CURRENT_USER'; Reg.OpenKey ('Control Panel / Desktop', false); reg.writestring 'Title Wallpaper', '0'); reg.writeString ( 'Wallpaper', filelistbox1.filename); reg.closereg; reg.free; ◇ [DELPHI] on the keyboard constant name VK_BACK / VK_TAB / VK_RETURN / VK_SHIFT / VK_CONTROL / VK_MENU / VK_PAUSE / VK_ESCAPE / VK_SPACE / VK_EFT / VK_RIGHT / VK_UP / VK_DOWNF1 - F12: $ 70 (112) - $ 7B (123) AZ: $ 41 (65) - $ 5A (90) 0-9: $ 30 (48) $ 39 (57) ◇ [Delphi] Preliminary judgment program Native DELPHI software DOS Tips: This Program Must Be Run Under Win32.VC software DOS Tip: This Program Cannot Be Run in Dos Mode. ◇ [Delphi] Operation Cookieresponse. Cookies ("name") .Domain: = 'http://www.086net.com'; with response.cookies.add dobeginname: = 'username'; value: = 'username'; END ◇ [Delphi] Add to Document Menu connection Uses shellapi, shlobj; shaddtorecentdocs (Shard_path, pchar (filepath))); // Added ShaddtorecentDocs (Shard_Path, NIL); // Empty ◇ [Miscellaneous] Backup Intelligent ABC Input French Word Windows / System / User.RemWindows /system/tmmr.rem ◇ [Delphi] Judgment Mouse button if getasynckeyState (vk_lbutton) <> 0 THEN ... // Left button if getasynckeyState (vk_mbutt "ON) <> 0 THEN ... / / Middle key if getasynckeystate (vk_rbutton) <> 0 THEN ... / / Right button [Delphi] Set the maximum display of the Form onFormCreate event Self.Width: = Screen.width; Self .height: = screen.height; ◇ [DELPHI] button OnCreate event message receiving processing: Application.OnMessage: = MyOnMessage; procedure TForm1.MyOnMessage (var MSG: TMSG; var handle: Boolean); beginif msg.message = 256 then ... // any key if msg.Message = 112 Then ... // f1if msg.Message = 113 Then ... // f2nd; ◇ [Miscellaneous] hidden shared folder sharing effect: Access, but not Visible (in resource management, network neighbors) Take a shared name: Direction $ Access: // Computer / Dirction / ◇ [Java Script] Java Script page Common effects page 60 seconds to close <

Script language = "java script"> close window Close Set Home Set as Homepage Collection of this site Join channel ◇ [Delphi] text editing related checkbox1.checked: = not checkbox1.checked; if checkbox1.checked kilhedit1.font.stylle := Richedit1.style [fsbold] else richedit1.font.style = richedit1.font.style-[fsbold]// bold if checkbox1.checked the richedit1.font.style =RicHedit1.Font.Style [fsitalic] else Richedit1.font.stylele- [fsitalic]// i i c c 1 1 = = = = = = = = = = = = = = = = = = = = = = = = = = = = .style- [fsunderline] // Underline M Emo1.alignment: = taleftjustify; // left memo1.alignment: = tarightjustify; // Live Memo1.Alignment: = Tacenter; // Case [delphi] randomly generate text color randomize; // Random seed Memo1.font.color : = RGB (Random (255), Random (255), Random (255)); ◇ [Delphi] Delphi5 Update Upgrade Patch Serial No. 100000318590X25FX0 ◇ [Delphi] file name illegal character filtering for i: = 1 to Length (S ) doif s ['/', '/', ':', '*', '?', '<', '>', '|'

] THEN ◇ [Delphi] Conversion Function and Description DateTimetOfileDate (DateTime: tdatetime): longint; convert the datetime value of the TDATETIME format to DOS format DateTimetostr (datetime: tdatetime): string; convert TDataTime format variable conversion Based on the string, if the datetime parameter does not include the date value, the return string date is displayed to be 00/00/00, if there is no time value in the DateTime parameter, the time part of the return string is displayed to be 00:00:00 AM DateTimetostring (VAR Result string; const format: String; DateTime: tdatetime); According to the given format string conversion time and date value, Result is the result string, format is the conversion format string, and DateTime is DateTostr (Date: tdatetime) The format string defined using the ShortDateFormat global variable converts the DATE parameter into the corresponding string floattodecimal (Var Result: TfloatRec; value: extended; Precision, Decimals: integer); convert the floating point number into a decimal representation FLOATTOSTR (value: extended): String converts floating point value VALUE into a string format, which uses a normal digital format, and the number of valid bits of the conversion is 15 bits. FLOATTETEXT (Buffer: Pchar; Value: Extended; Format: Tfloatformat; Precision, Digits: Integer: Integer; Convert the floating point value value VALUE into a decimal representation with a given format, accuracy and decimal, and the conversion results are stored in the buffer parameter The function return value is the number of characters stored in the buffer, and buffer is a string buffer with non-zero results. FLOATTETEXTFMT (Buffer: Pchar; Value: Extended; Format: Pchar): Integer Converts floating point value value VALUE into a decimal form in a given format, the conversion result is stored in the buffer parameter, the function returns the value stored in the buffer. Bit number. INTTOHEX (value: long): string; converts a given value value value into hexadecimal strings. Parameter DIGITS gives the number of digits contained in the conversion result string. INTOSTR (Value: longint): String converts an integer into a decimal form string strandate (const S: String): TDATETIME converts a string into a date value, and s must contain a list of legitimate formatted dates. STRTODATETIME (const S: string): TDATETIME converts string S to date time format, s must have mm / dd / yy hh: mm: SS [AM | PM] format, where date and time separator and system time constant Set. If the AM or PM information is not specified, it means 24 hours.

STRTOFLOAT (Const S: String): Extended; converts a given string into floating point numbers, strings have the following format: [ | -] nnn ... [.] nnn ... [< | -> < | -> nnnn] start (const S: String): Longint converts the numeric string into an integer, the string can be a decimal or hexadecimal format, if the string is not a legitimate digital string, the system occurs EconvertError Abnormal Strtointdef (Const: String; Default: long): longint; converts string S into numbers, if S is not converted into numbers, the STRTOINTDEF function returns the value of parameter default. Strtotime (const s: string): TDATTIME converts strings S to TDATETIME values, S has HH: MM: Ss [AM | PM] format, the actual format is related to the overall variable related to the system time. Timetostr (Time: TDATETIME): String; convert the parameter time into a string. The format of the conversion result string is related to the setting of the time-related constant of the system.

◇ [DELPHI] procedure does not appear to add ALT CTRL DEL statement after implementation: function RegisterServiceProcess (dwProcessID, dwType: Integer): Integer; stdcall; external 'KERNEL32.DLL'; RegisterServiceProcess (GetCurrentProcessID, 1); // Hide RegisterServiceProcess (getCurrentProcessid, 0); // Display ALT DEL CTRL can not see ◇ [Delphi] program does not appear in the taskbar Uses WindowsvarextendedStyle: Integer; beginApplication.initialize; // =========== ============================================================================================================================================================================================================= = ExtendedStyle: = GetWindowLong (Application.Handle, GWL_EXSTYLE); SetWindowLong (Application.Handle, GWL_EXSTYLE, ExtendedStyle OR WS_EX_TOOLWINDOWAND NOT WS_EX_APPWINDOW); // ==================== =================================================== Application.createform (TFORM1, FORM1 Application.run; end. ◇ [Delphi] How to determine the dial-up network is the turn of getSystemMetrics (SM_Network) and $ 01 = $ 01 THEN ShowMessage ('Online!') Else ShowMessage ('Not online!'); ◇ [Delphi ] Convert Function GetDomainName (IP: String): String; Var Ph: PHOSTENT; DATA: TWSADATA; II: DTA: TWSADATA; II: = INET_ADDR (PCHAR (IP); pH: PH: = gethostbyadd R (@ ii, sizeof (ii), pf_inet); if (pH <> nil) ThenResult: = ph.h_namelse result: = '; wsacleanup; end; ◇ [Delphi] Processing "Right-click Menu" method VARREG: TREGISTRY BeginReg: = Tregistry.create;

REG.ROOTKEY: = HKEY_CLASSES_ROOT; reg.OpenKey ('* / shell / check / command', true); reg.writeString ('', '"" "" "% 1"); REG. CloseKey; Reg.openkey ('* / shell / diary', false); reg.writestring ('', 'operation (& c); reg.closekey; regree; showMessage; end; ◇ [Delphi] Send Virtual Key Values ​​Ctrl vProcedure SendPaste; BeginkeyBD_Event (VK_Control, MapVirtualKey (VK_Control, 0), 0, 0); KeyBD_Event (ORD ('V'), MapVirtualKey (ORD ('V'), 0), 0 , 0); KeyBD_EVENT (ORD ('V'), MapVirtualKey (ORD ('V'), 0), KeyEventf_Keyup, 0); KeyBD_Event (VK_Control, MapVirtualKey (vk_control, 0), KeyEventf_Keyup, 0); End; ◇ [ Delphi] Current CD-ROL DVOM (VAR CD: Char); Varstr: String; Drivers: Integer; Driver: CHAR; I, TEMP: Integer; Begindrivers: = getLogicalDrives; Temp: = (1 and drivers); for I: = 0 to 26 dobeginif Temp = 1 Thenbegindriver: = CHAR (i integer ('a')); str: = driver '; if getDriveType (PCHAR (STR)) = drive_cdrom damimegind: = driver; End; end; drivers: = (Drivers SHR 1); Temp: = (1 and drivers); end; end; ◇ [Delphi] character's encryption and decryption Function Cryptstr (const S: string; stype: DWORD; string; vari: integer; fkey: integer; beginResult: = '; case stype of0: setPass; beginrandomize; fkey: = random ($ ff); for i: = 1 to Length (s) doreSult: = Result CHR (ORD (S [i]) xor fkey); Result: = Result char (fkey); end; 1: getpassbeginfkey: = ORD (s)]); for i: = 1 To Length (s) - 1 doreSult: = Result chr (ORD (S [i]) xor i xor fkey); end; end; □ ◇ [Delphi] Send analog key to other applications VARH: Thandle; Beginh: = FindWindow (NIL, 'application title'); PostMessage (h, wm_keydown, vk_f9, 0); // Send F9 key END;

□ □ [Delphi] Delphi supported DAO data format Td.fields.Append (TD.CREATEFIELD ('dbbolean', dbbolean, 0)); TD.Fields.Append ('dbbyte', dbbyte, 0))) Td.fields.Append ('dbinteger', dbinteger, 0)); TD.Fields.Append (Td.createField ('dblong', dblong, 0)); TD.Fields.Append (TD.CREATEFIELD ('dbcurrency, 0); td.fields.append (Td.createField (' dbsingle ', dbsingle, 0)); TD.Fields.Append (Td.createfield (' dbdouble ', dbdouble, 0)) Td.fields.Append (TD.CREATEFIELD ('DBDATE', DBDATE, 0); TD.Fields.Append (Td.createField ('dbinary', dbbonary, 0)); td.fields.Append (TD.CREATEFIELD ('dbtext', dbtext, 0); td.fields.Append ('dblongbinary', dblongbinary, 0)); td.fields.append (TD.CREATEFIELD ('DBMEMO', DBMEMO, 0)))) TD.fields ['id']. set_attributes (dbautoinCrfield); // Self-adding field □ □ [Delphi] Delphi Configuration MS SQL 7 and BDE steps first step, configure ODBC: set up data sources in ODBC, installed After SQL Server 7.0, there is a "system DSN" in the ODBC, there should be two data sources, one is MQIS, one is localsever, optionally a selected click configuration button, I don't know if your SQL7.0 is installed in the local machine On, if it is the next step, if not, fill in Server in the server column, then make the next step, fill in the login ID and password (login ID, and password are set in the user option in SQL7.0) ). Step 2, configure BDE: Open Delphi BDE, then click MQIS or LocalServer, you will prompt the username and password, which is the same as the ODBC username and password, fill it. Step 3, the configuration program: If you use a TTable, select MQIS or LocalServer in the TTable DatabaseName, then select Sale in TableName, then change the Active to True, Delphi pops up the prompt dialog, fill in the username and password . If you use tQuery, click the right button on TQuery, then strike "SQL Builder", which is configured in the interface to configure the SQL statement, or fill in the SQL statement in the TQUERY SQL. Finally, don't forget to change Active to True. It is also possible to configure TQuery, see Delphi Help.

□ □ [delphi] Gets a point of the image on a point of the RGB value TFORM1.IMAGE1MOUSEDOWN (Sender: Tobject; Button: TMouseButton; Shift: TshiftState; x, y: integer; varred, green, blue: byte; i: integer; begini = Image1.canvas.pixels [x, y]; blue: = getBValue (i); green: = getgvalue (i): red: = getRvalue (i); label1.caption: = INTOSTR (red); label2.caption : = INTOSTR (Green); label3.caption: = INTOSTOSTR (Blue); end; □ □ [Delphi] About Date Format Decomposition Translation VAR Year, Month, Day: Word; Now2: TDataime; NOW2: = Date (); decodedate (Now2, Year, Month, Day); Lable1.text: = INTSTOSTR (YEAR) 'Year' INTOSTR (MONTH) 'Moon' INTOSTR (DAY) 'Day'; ◇ [Delphi] How to judge the current network The connection method is the result of the MODEM, a local area network, or a proxy server. uses wininet; Function ConnectionKind: boolean; var flags: dword; begin Result: = InternetGetConnectedState (@flags, 0); if Result then begin if (flags and INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM then begin showmessage ( 'Modem'); end; if ( flags and INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN then begin showmessage ( 'LAN'); end; if (flags and INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY then begin showmessage ( 'Proxy'); end; if (flags and INTERNET_CONNECTION_MODEM_BUSY) = INTERNET_CONNECTION_MODEM_BUSY then begin showmessage ( 'Modem Busy '); end; end; end; ◇ [Delphi] how to determine if the string is a valid email address Function Isemail (email: string): boolean; var s: string; etc: integer; begin etpos: = POS (' @ ', Email); if etc = copy (Email, ETPOS 1, Length (email)); if (POS ('. ', S)> 1) and (POS ('. ', S

Function is declared as: function InetIsOffline (Flag: Integer): Boolean; stdcall; external 'URL.DLL'; then can call the function determines whether the system is connected to INTERNETif InetIsOffline (0) then ShowMessage else ShowMessage (( 'not connected!') 'Connected!'); This function returns true if the local system is not connected to the Internet. Attachment: Most systems with IE or Office97 have this DLL for call.

InetIsOfflineBOOL InetIsOffline (DWORD dwFlags,); ◇ [DELPHI] simply play and pause WAV files uses mmsystem; function PlayWav (const FileName: string): Boolean; begin Result: = PlaySound (PChar (FileName), 0, SND_ASYNC); end Procedure stopwav; var buffer: array [0..2] of char; becom buffer [0]: = # 0; Playsound (buffer, 0, snd_purge); end; ◇ [Delphi] Take the machine BIOS information with memo1.Lines Do Begin Add ('mainboardbiosname:' ^ i string (PCHAR (PTR ($ FE061))))))))); add ('mainboardbioscopyright:' ^ i string (PCHAR (Ptr (PTR ($ FE091)))); add ( 'MainboardBiosDate:' ^ i string (PCHAR (PTR ($ FFFF5))))))))); add ('mainboardbiosserialno:' ^ i string (pchar (Ptr (PTR ($ FEC71))))); end; ◇ [Delphi] Network Download File Urlmon; Function Downloadfile (Source, Dest: String): Boolean; Begin Try Result: = URLDOWNLOADTOFILE (NIL, PCHAR (SOURCE), PCHAR (DEST), 0, NIL) = 0; Except Result: = false end; end; if DownloadFile ( 'http://www.borland.com/delphi6.zip,' c: /kylix.zip ') then ShowMessage (' Download succesful ') else ShowMessage (' Download unsuccesful ') ◇ [DELPHI ] Resolution Server IP Address Uses Winsock Function ipaddrtoname (i PAddr: String): String; var SockAddrIn: TSockAddrIn; HostEnt: PHostEnt; WSAData: TWSAData; begin WSAStartup ($ 101, WSAData); SockAddrIn.sin_addr.s_addr: = inet_addr (PChar (IPAddr)); HostEnt: = gethostbyaddr (@SockAddrIn .SIN_ADDR.S_ADDR, 4, AF_INET); if Hostent <> nil the result: = strpas (hostent ^ .h_name) Else Result: = '; end; ◇ [Delphi] A connection in shortcut Function ExeFromLink (Const LinkName : string): string; var fDir, FName, ExeName: PChar; z: integer; begin ExeName: = StrAlloc (MAX_PATH); FName: = StrAlloc (MAX_PATH); fDir: = StrAlloc (MAX_PATH); StrPCopy (FName, ExtractFileName ( LinkName));

StrPCopy (FDir, ExtractFilePath (linkname)); z: = FindExecutable (FName, FDir, ExeName); if z> 32 then Result: = StrPas (ExeName) else Result: = ''; StrDispose (FDir); StrDispose (FName) ; StrDispose (ExeName); end; ◇ [DELPHI] TComboBox control autocomplete { 'Sorted' property of the TCombobox to true} var lastKey: Word; // // TCombobox the global variable OnChange event procedure TForm1.AutoCompleteChange (Sender: TObject); var searchStr: string; retVal: integer; begin searchStr: = (Sender as TCombobox) .Text; if lastKey <> VK_BACK then // backspace: VK_BACK or $ 08 begin retVal: = (Sender as TCombobox) .Perform (CB_FINDSTRING , -1, longint (searchstr)); if return> CB_ERR THEN BEGIN (Sender as TcomboBox) .ItemIndex: = RetVal; (Selstart: = Length (SearchStr); (Sender AS TCOMBOBOX). SelLength: = ((Sender as Tcombobox) .text) - length (searchstr)); end; // RetVal> CB_ERR END; // LastKey <> vk_back lastkey: = 0; // reset lastkey end; // tcomboBox OnkeyDown event procedure tform1.autocompleteKeydown (Sender: Tobject; VA r Key: Word; Shift: TShiftState); begin lastKey: = Key; end; ◇ [DELPHI] How to clear a directory function EmptyDirectory (TheDirectory: String; Recursive: Boolean): Boolean; varSearchRec: TSearchRec; Res: Integer; beginResult: = False; TheDirectory: = NormalDir (TheDirectory); Res:; ( '.' SearchRec.Name <>) = FindFirst (TheDirectory '. * *', faAnyFile, SearchRec) trywhile Res = 0 dobeginif and (SearchRec.Name < > '..') thenbeginif ((SearchRec.Attr and faDirectory)> 0) and Recursivethen beginEmptyDirectory (TheDirectory SearchRec.Name, True); RemoveDirectory (PChar (TheDirectory SearchRec.Name));

endelse beginDeleteFile (PChar (TheDirectory SearchRec.Name)) end; end; Res: = FindNext (SearchRec); end; Result: = True; finallyFindClose (SearchRec.FindHandle); end; end; ◇ [DELPHI] How to calculate a directory size function GetDirectorySize (const ADirectory: string): Integer; varDir: TSearchRec; Ret: integer; Path: string; beginResult: = 0; Path: = ExtractFilePath (ADirectory); Ret: = Sysutils.FindFirst (ADirectory, faAnyFile, Dir ); if RET <> NO_ERROR THEN EXIT; trywhile ret = no_error dobegininc (result, dir.size); if (dir.attr in [fadirectory]) and (dir.name [1] <> '.'). ').' GetDirectorySize (Path Dir.name '/*. *)): = sysutils.FindNext (Dir); end; finallysysutils.FindClose (DIR); end; end; ◇ [Delphi] installer how to add it to how Uninstall list operation registry, as follows: 1. Create a primary key under HKEY_LOCAL_MACHINE / CURRENTVERSION / UNINSTALL key, and the name is arbitrary. Example HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Windows / CurrentVersion / Uninstall / MyUninstall2 in HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Windows / CurrentVersion / Uninstall / MyUnistall two string values ​​under the key, the two string value of the name is specific: DisplayName and UninstallString .

3. Give a DISPLAYNAME assignments to the name in the "Delete Application List", such as 'aIming Uninstall One'; assigning the delete commands executed by the strey uninstallString, such as c: /win97/uninst.exe -f "C: /TestPro/aimTest.isu"◇[DELPHI] WM_QUERYENDSESSION shutdown message intercepted typeTForm1 = class (TForm) procedure WMQueryEndSession (var message: TWMQueryEndSession); message WM_QUERYENDSESSION; procedure CMEraseBkgnd (var message: TWMEraseBkgnd); message WM_ERASEBKGND; private {Private declarations} public {public declarations} end; procedure TForm1.WMQueryEndSession (var Message: TWMQueryEndSession); beginShowmessage ( 'computer is about to shut down'); end; ◇ [DELPHI] Get Network neighborhood procedure getnethood (); // NT server to do, Win98 is debugged.

vara, i: integer; errcode: integer; netres: array [0..1023] of netresource; enumhandle: thandle; enumentries: dword; buffersize: dword; s: string; mylistitems: tlistitems; mylistitem: tlistitem; alldomain: tstrings; begin // listcomputer is a listview to list all computers; controlcenter is a form.alldomain: = tstringlist.Create; with netres [0] do begindwscope: = RESOURCE_GLOBALNET; dwtype: = RESOURCETYPE_ANY; dwdisplaytype: = RESOURCEDISPLAYTYPE_DOMAIN; dwusage: = RESOURCEUSAGE_CONTAINER; lplocalname: = nil; lpremotename: = nil; lpcomment: = nil; lpprovider: = nil; end; // get all fields errcode: = wnetopenenum (RESOURCE_GLOBALNET, RESOURCETYPE_ANY, RESOURCEUSAGE_CONTAINER, @ netres [0], enumhandle); if errcode = NO_ERROR then beginenumentries: = 1024; buffersize: = sizeof (netres); errcode: = wnetenumresource (enumhandle, enumentries, @ netres [0], buffersize); end; a: = 0; mylistitems: = controlcenter.lstcomputer.Items; MYLISTITEMS.CLEAR; while (Netres [a] .lpprovider <> ') AND (errcode = no_error) dobeginaldomain.add (NetRes [a] .lpremotename); A: = a 1; end; WnetClo seenum (enumhandle); // get all computers mylistitems: = controlcenter.lstcomputer.Items; mylistitems.Clear; for i: = 0 to alldomain.Count-1 dobeginwith netres [0] do begindwscope: = RESOURCE_GLOBALNET; dwtype: = RESOURCETYPE_ANY ; dwdisplaytype: = RESOURCEDISPLAYTYPE_SERVER; dwusage: = RESOURCEUSAGE_CONTAINER; lplocalname: = nil; lpremotename: = pchar (alldomain [i]); lpcomment: = nil; lpprovider: = nil; end; ErrCode: = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_ANY, RESOURCEUSAGE_CONTAINER, @Netres [0], enumhandle; if errcode = no_error dameginenumentries: = 1024; buffersize: = sizeof (Netres); errcode: =

WneetenumResource (EnumHandle, ENUMENTRIES, @ NetRes [0], Buffersize; end; A: = 0; while (string (netres [a] .lpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppProiStitem: = myListItems.Add MyListItem.imageIndex: = 0; MyListItem.caption: = Uppercase (StringReplace (StringReplace (String (Netres [a] .lpremotename), '//', '', [RFREPLACEALL]); A: = A 1; END; wnetcloseenum (enumhandle); end; end; ◇ [DELPHI] Gets procedure getsharefolder shared directory on a computer (const computername: string); varerrcode, a: integer; netres: array [0..1023] of netresource; enumhandle: thandle; enumentries, buffersize: dword; s: string; mylistitems: tlistitems; mylistitem: tlistitem; mystrings: tstringlist; beginwith netres [0] do begindwscope: = RESOURCE_GLOBALNET; dwtype: = RESOURCETYPE_DISK; dwdisplaytype: = RESOURCEDISPLAYTYPE_SHARE; dwusage: = RESOURCEUSAGE_CONTAINER; lplocalname: = nil; lpremotename: = pchar (computername); lpcomment: = nil; lpprovider: = nil; end; // Get the root errcode: = wnetopenenum (RESOURCE_GLOBALNET, RESOURCETYPE_DISK, RESOURCEUSAGE_CONTAINER, @ netres [0], enumhandle) If errcode = no_ERROR THENBEGINENUMEN tries: = 1024; BufferSize: = SizeOf (NetRes); ErrCode: = WNetEnumResource (EnumHandle, EnumEntries, @ NetRes [0], BufferSize); end; wnetcloseenum (enumhandle); a: = 0; mylistitems: = controlcenter.lstfile. Items; mylistitems.Clear; while (string (netres [a] .lpprovider) <> '') and (errcode = NO_ERROR) dobeginwith mylistitems dobeginmylistitem: = add; mylistitem.ImageIndex: = 4; mylistitem.Caption: = extractfilename (netres [A] .lpremotename; end; a: = a 1; end; end; ◇ [delphi] gets hard disk serial number var Serialnum: pdword; A, B: DWORD; buffer: array [0..255] of char Begin if getVolumeInformation ('c: /'

, Buffer, Sizeof (Buffer), Serialnum, A, B, NIL, 0) THEN Label1.caption: = INTOSTR (Serialnum ^); End; ◇ [Delphi] MEMO automatic page flooding Procedure ScrollMemo (Memo: TMEMO; Direction: char); begin case direction of 'd': begin SendMessage (Memo.Handle, {HWND of the Memo Control} WM_VSCROLL, {Windows Message} SB_PAGEDOWN, {Scroll Command} 0) {Not Used} end; 'u': begin SendMessage (Memo.Handle, {HWND of the Memo Control} WM_VSCROLL, {Windows Message} SB_PAGEUP, {Scroll Command} 0); {Not Used} end; end; end; procedure TForm1.Button1Click (Sender: TObject); begin ScrollMemo (Memo1, 'D'); // Turn page End; Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); Begin ScrollMemo (Memo1, 'u'); // Turn the page END; ◇ [Delphi] DBGRID to the next position (Tab key) procedure TForm1.DBGrid1KeyPress (Sender: TObject; var key: Char); beginif key = # 13 thenif DBGrid1.Columns.Grid.SelectedIndex Install component ..-> PAS or DCU file -> install2. For control packages with * .dpk files , File -> Open (select * .dpk in the drop-down list box) -> install .3. For the control package with * .dpl file, the install package-> add -> DPL file name. 4. If the above Install button is invalid, try the Compile button. 5. Yes Run Time Lib's RuntimePacke under the package of Packages under Option. If you can't find the prompt, you can find the file, it is generally the control of the control. There are two ways to solve: 1. Put The installed original file is copied into the lib directory of Delphi. 2. Or Tools -> Environment Options Add the control original code path to the lib directory of Delphi.

◇ [DELPHI] directory completely removed (deltree) procedure TForm1.DeleteDirectory (strDir: String); var sr: TSearchRec; FileAttrs: Integer; strfilename: string; strPth: string; begin strpth: = Getcurrentdir (); FileAttrs: = faAnyFile; IF FindFirst (StrPth '/' strdir '/ *. *', FileAtTRS, SR) = 0 THEN BEGIN IF (sr.attr and fileattrs) = sr.attr the begin strfilename: = sr.name; if FileExists (StrPth ) / ' strdir ' / ' strfilename) Then Deletefile (StrPth ' / ' strdir ' / ' strfilename); end; while findnext (sr) = 0 do begin if (sr.attr and fileattrs) = sr.attr THEN begin strfilename: = sr.name; if fileexists (strpth '/' strdir '/' strfilename) then deletefile (strpth '/' strdir '/' strfilename); end; end; FindClose (sr); removedir ( Strpth '/' strdir); end; end; ◇ [Delphi] gets the current cursor of the TMEMO control. Row and column information to TPOINT 1.Function ReadCursorpos (SourceMemo: TMEMO): TPOINT; VAR POINT: TPOINT; Begin Point: : = SendMessage (SourceMemo.handle, EM_LineFromchar, SourceMemo.selstart, 0); Point.x: = SourceMemo.selstart-sendMessage (SourceMemo.handle, EM_LINEINDEX, POINT.Y, 0); RESULT: = POINT; END; 2.LineLength: = SendMessage (Memol. Handle, EM-LINELENGTH, CPOS, 0); // President [Delphi] Read hard disk serial number function getDiskSerial (Diskcha: char): string; varserialnum: pdword; A, B: DWORD; buffer: array [0 .. 255] OF CHAR; BeginResult: = ""; if GetVolumeInformation (Pchar (Diskcha ": /"), Buffer, Sizeof (Buffer), Serialnum, A, B, NIL, 0) THEN Result: = INTOSTR (Serialnum ^); END; ◇ [Internet] CSS common comprehensive skills 1.

P: first-letter {font-size: 300%; float: Left} // The first word will increase three times more than ordinary fonts. 2. // Connect an external style table 3. Embed a style sheet