The ancestors' Delphi Basic Development Skills

xiaoxiao2021-03-06  79

◇ [Delphi] Network neighbor replication file Uses shellapi; copyfile (Pchar ('newfile.txt'), Pchar ('// computername / direction / targer.txt'), false);

◇ [Delphi] Generates the mouse drag effect Through Mousemove event, Dragover event, enddrag event implementation, such as Label: Var XPanel, Ypanel, XLabel, Ylabel: Integer; XPanel: = X; YPANEL: XPANel: = x; Ypanel: = Y; Panel's Dragover event: xPanel: = X; YPANEL: = Y; Label Mousemove event: xlabel: = x; ylabel: = y; label's endDrag event: label.Top: = xpanel-xlabel; label.top : = YPANEL-YLABEL;

◇ [Delphi] gets Windows catalog Uses shellapi; var window, array [0..255] of char; getWindowsDirectory; or read from the registry, location: hkey_local_machine / Software / Microsoft / WINDOWS / CurrentVersionsystemroot key, acquisition, C: / Windows

◇ [delphi] Pipeline VAR X, Y: Array [0..50] of integer; canvas.pen.color: = CLRED; canvash; form1.canvas.moveto (Trunc (x [i]), trunc (y [i])); Form1.canvas.LineTo (Trunc (x [j]), trunc (y [j]));

◇ [Delphi] string list use var tips: tstringlist; tips: = tstringlist.create; tips.loadfromfile ('filename.txt'); edit1.text: = tips [0]; tips.add ('Last Line Additional String '); Tips.insert (1,' INSERT STRING AT NO 2 line '); tips.savetofile (' newfile.txt '); tips.free;

◇ [Delphi] Simple clipboard operates richedit1.selectall; richedit1.copytoclipboard; richedit1.cuttoclipboard; edit1.pastefromclipboard;

◇ [Delphi] About file, directory operation 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 work 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] Processing file attribute Attr: = filegetattr (fileListBox1.filename); if (attridadonly) = FareadOnly the ... // read-only if (attr and fasysfile) = FasysFile dam // System IF Attr and faarchive) = Faarchive the ... // Archive IF (attr and fahidden) = Fahidden Then ... // Hide ◇ [Delphi] Export File Winexec // Call Up 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] acquiring 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 (@sztext)); hcurrentWindow: = getWindow (HcurrentWindow, GW_HWndNext); end;

◇ [Delphi] embedded ASM end in assembly; can modify Eax, ECX, EDX can be arbitrarily modified; ESI, EDI, ESP, EBP, EBX can not be modified.

◇ [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 Tips: 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] Added to the document menu connection Uses shellapi, shlobj; shaddtorecentdocs (Shard_Path, Pchar (filepath)); // Added ShaddtorecentDocs (Shard_Path, NIL); // Clear

◇ [Miscellaneous] Backup Intelligent ABC Input French Word Library Windows / System / User.RemWindows / System / Tmmr.Rem

◇ [Delphi] Judgment Mouse Buttons If getasyncKeyState (vk_lbutton) <> 0 THEN ... // Left button if getasynckeystate (vk_mbutton) <> 0 Then ... // 中键 f 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 accepts the message oncreate event: 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 ... / / F2END;

◇ [Miscellaneous] Hide Shared Folder Sharing Effect: Access, but invisible (in resource management, network neighbors) Take a shared name: Direction $ Access: // Computer / Dirction /

◇ [Java Script] Java Script webpage Common effects page 60 second timing Close