Delphi Basic Development Skills (1)

xiaoxiao2021-03-06  104

Delphi Basic Development Skills [Delphi] Network Neighbor Replication Document Uses Shellapi; CopyFile (Pchar ('NewFile.txt'), Pchar ('// Computername / Direction / Targer.txt'), False); ◇ [Delphi] Generate mouse Drag Effects through the Mousemove event, Dragover event, Enddrag event implementation, such as Label: Var XPanel, Ypanel, XLabel, Ylabel: Integer, 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] 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 button, acquisition, 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]) ); ◇ [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 Str ing at NO 2 line '); tips.savetofile (' newfile.txt '); tips.free; ◇ [DELPHI] clipboard simple operation richedit1.selectall; richedit1.copytoclipboard; richedit1.cuttoclipboard; edit1.pastefromclipboard; ◇ [ Delphi] About file, directory operation chDIR ('c: / abcdir'); go to directory mkdir ('DIRNAME'); establish directory RMDir ('DIRNAME'); delete directory getcurrentdir; // Take the current directory name, no '/ 'Getdir (0, s); // Take the work directory name S: =' c: / abcdir '; deleetfile (' abc.txt '); // Remove file renamefile (' ild.txt ',' new.txt ' ); // file rename extractFileName (filename); // Take a file name extractFileExt (filelistbox1.filename); // Take a file suffix ◇ [Delphi] Process file attribute attr: = filegetttr (fileEListBox1.filename); if (Attr And fareadonly) =

Fareadonly kiln ... // read-only if (attr and fasysfile) = fasysfile kiln ... // System IF (attr and faarch) = faarchive dam // Archive IF (attr and fahidden) = Fahidden Then .. . // Hide ◇ [Delphi] Execute the program external file Winexec // Call the executable WINEXEC ('Command.com / c copy *. * C: /', sw_normal); Winexec ('start abc.txt'); Shellexecute Or SHELLEXECUTEEX // Start File Related 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; end; ◇ [delphi] About assembly analog ASM END; can modify Eax, ECX , EDX; You cannot modify 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 It can be seen (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

Turning off the window Close the timing to the URL data source, one is MQIS, one is a localsever, optionally a selected click configuration button, I don't know if your SQL7.0 is installed on the local machine, if not, let's go directly, if not In the server column, fill in Server, then perform the next step, fill in the login ID and password (the 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

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));

转载请注明原文地址:https://www.9cbs.com/read-123980.html

New Post(0)