Delphi Basic Development Skills

xiaoxiao2021-03-06  51

? ◇ [Delphi] Network neighbor replication file Uses shellapi; copyfile (pchar ('newfile.txt'), pchar ('// computername / direction / targer.txt'), false); ◇ [Delphi] produces mouse drag effect Implementing the Mousemove event, Dragover event, Enddrag event, for example on the label: Var XPanel, Ypanel, XLabel, YLabel: Integer; XPanel: = X; YPANEL: = Y; PANEL DRAGOVER Event: XPanel : = x; YPANEL: = Y; Mousemove event: xlabel: = x; ylabel: = y; label's enddrag event: label.left: = xPanel-xlabel; label.top: = YPANEL-YLABEL; ◇ [Delphi ] Get 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 , Acquisition, C: / Windows [Delphi] on Form or other container, line 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 Additional String " Tips.insert (1, 'Insert String At n O 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'); // Delete file renamefile ('ly.txt', 'new.txt'); // Document Name of ExtractFileName (fileEListBox1.FileName); // Take the file name extractFileExt (filelistbox1.filename); // Take the 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 Buttons If getasynckeyState (vk_lbutton) <> 0 Then ... // Left button if getasynckeyState (vk_ Mbutton <> 0 THEN ... / / Middle key if getasynckeystate (vk_rbutton) <> 0 THEN ... / / Right-click [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 closing timing URL

Set as Homepage Home Favorite This site Add to Channel Add Channel ◇ [Delphi] Random Generate Text Color Randomize; // Random Seed Memo1.Font.Color: = RGB (255), Random (255)); ◇ [DELPHI] DELPHI5 UPDATE Upgrade Patch Serial No. 100000318590X25FX0 ◇ [Delphi] File Name illegal Filter FOR i: = 1 to Length (S) Doif S [I] in ['/', '/' , ':', '*', '?', '<', '>', '|'] The definition of "Delphi] conversion function and Description DateTimetOfileDate (datetime: tdatetime): longint; Date of TDATETIME format The time value is converted to the DOS format DateTimetostr (datetime: tdatetime): String; convert the TDataTime format variable into a string, if the datetime parameter does not contain the date value, return the string date is displayed to be 00/00/00, if DateTime There is no time value in the parameter, the time part of the return string is displayed to be 00:00:00 AmdateTimetString (Var Result string; const format: string; datetime: tdatetime); transition time and date value based on a given format string, Result For the result string, format is the conversion format string, DateTime uses the format string defined by the date time value DateTostr (date: tdatetime) Use the shortdateformat global variable to convert the DATE parameter into a corresponding string FLOATTODECIMAL (VAR RESULT: TFLOATREC; VALUE: Extended; Precision, Decimals: Integer; convert 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, converted the effective bit of 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]

StrtOINT (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 exception

StrtoinTdef (Const S: String; Default:

LONGINT: longint; converts the string S into a number, if the S is not converted into a number, the StrtOINTDEF function returns the value of the 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 THENSHOWMESSAGE ('online!') Else ShowMessage; ◇ [Delphi] Convert Function GetDomainName (IP: String): String; Varph: Phostent; Data: TWSADATA; II: DTA: TWSADATA; II: DTA: TWSADATA; II: = INET_ADDR (Pchar (IP)); ph: pH: = gethOstbyAddr ( @ II, SIZEOF (II), PF_INET; IF (pH <> nil) ThenResult: = ph.h_nameelseresult: = '; 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 thenbegIncd: = driver; exit; End; end; drivers: = (Drivers SHR 1); TEMP: = (1 and drivers); end; end; ◇ [Delphi] character encryption and decryption Function Cryptstr (const s: string; stype : dword: string; vari: integer; fkey: integer; beginResult: = '; case stype ='; 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 [length (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, 'Applicate 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; beginResult: = InternetGetConnectedState (@flags, 0); if Result thenbeginif (flags and INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM thenbeginshowmessage ( 'Modem'); end; if (flags and INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN thenbeginshowmessage ( 'LAN'); end; if (flags and INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY thenbeginshowmessage ( 'Proxy'); end; if (flags and INTERNET_CONNECTION_MODEM_BUSY) = INTERNET_CONNECTION_MODEM_BUSY thenbeginshowmessage ( '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 = POS: Integer; becomes: = POS ('@', email); if etc @ @ @ ', email); if etc COPY (Email, ETPOS 1, Length); 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; beginResult: = PlaySound (PChar (FileName), 0, SND_ASYNC); end; Procedure stopwav; varbuffer: array [0..2] of char; becombuffler [0]: = # 0; Playsound (buffer, 0, snd_purge); end; ◇ [Delphi] take machine BIOS information with memo1.line dobeginadd (' 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 ($ FEC71))))); end; ◇ [delphi] network Download File URLMON ; function DownloadFile (Source, Dest: string): Boolean; begintryResult: = UrlDownloadToFile (nil, PChar (source), PChar (Dest), 0, nil) = 0; exceptResult: = False; end; end; if DownloadFile ( ' http://www.borland.com/delphi6.zip, 'c: /kylix.zip') thenShowMessage ( 'Download succesful') else ShowMessage ( 'Download unsuccesful') ◇ [DELPHI] resolve the IP address of the server uses winsock function IPAddrToName (Ipaddr: string): STRIN g; varSockAddrIn: TSockAddrIn; HostEnt: PHostEnt; WSAData: TWSAData; beginWSAStartup ($ 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] getting the connection in the shortcut function exeFromLink (const linkname: string): string; varFDir , FName, ExeName: PChar; z: integer; beginExeName: = 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 thenResult: = StrPas (ExeName) elseResult: = ''; StrDispose (FDir); StrDispose (FName); StrDispose (ExeName); end; ◇ [DELPHI] Control TCombobox of automatically { 'Sorted' property of the TCombobox to true} var lastKey: Word; // // TCombobox the global variable OnChange event procedure Tform1.AutoCompleteChange (Sender: TObject); varSearchStr: string; retVal: integer; beginSearchStr: = ( Sender as TCombobox) .Text; if lastKey <> VK_BACK then // backspace: VK_BACK or $ 08beginretVal: = (Sender as TCombobox) .Perform (CB_FINDSTRING, -1, LongInt (PChar (searchStr))); if retVal> CB_Err thenbegin (Sender as tcombobox) .itemindex: = RETVAL; (Sender as tcombobo). SELSTART: = Length (SearchStr); (Sender as tcomboBox) .sellength: = (Length (Sender as tcombox) .text) - Length (SearchStr) ); end; // retVal> CB_Errend; // lastKey <> VK_BACKlastKey: = 0; // reset lastKeyend; // onKeyDown event TCombobox the procedure Tform1.AutoCompleteKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState); BeginlastKey: = key; end; ◇ [Delphi] How to empty a directory fu nction EmptyDirectory (TheDirectory: String; Recursive: Boolean): Boolean; varSearchRec: TSearchRec; Res: Integer; beginResult: = False; TheDirectory: = NormalDir (TheDirectory); Res: = FindFirst (TheDirectory '. * *', faAnyFile, SearchRec); trywhile Res = 0 dobeginif ( '.' SearchRec.Name <>) and (SearchRec.Name <> '..') thenbeginif ((SearchRec.Attr and faDirectory)> 0) and Recursivethen beginEmptyDirectory (TheDirectory SearchRec. Name, true); RemoveDirectory; endelse becomeletefile (Pchar (ThetIRectory SearchRec.name) end; end; res: = findnext (searchRec);

Result: = True; finallyFindClose (SearchRec.FindHandle); end; end; ◇ [DELPHI] installer how to add a list of operations to Uninstall registry, as follows: 1 established under the HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Windows / CurrentVersion / Uninstall button. A primary key, 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 THENBEGINENUME ntries: = 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 Beginif GetVolumeInformation ('c: /'

, Buffer, Sizeof (Buffer), Serialnum, A, B, NIL, 0) THEN LABEL1.CAPTION: = INTOSTR (Serialnum ^); END; 1. About MDI Main Factory Background New Solution? Add image control to Form? ? Set the BMP image ?? Name is written in the CREATE event of IMG_BK ?? Self.brush.bitmap: = IMG_BK.Picture.bitmap; 2. Painting VCL control at the title bar (a line solving problem!! !) ?? In the ONPAINT event in Form ?? control .pointto (getdc (0), left, top); 3 Edit Enter only a number ??? SetWindowlong (Edit1.Handle, GWL_Style, ??????? ?????????? getWindowlong (edit1.handle, gwl_style) or ????????????????? ES_NUMBER); 4. Similar to MDI new solutions to set Child The oncreate mode is written under: ?????????? Self.Parent: = 'To set to Mainform's Form'; 5. Refresh's refresh (only one line!) RedRawwindow (0, nil, 0, RDW_ERASE or RDW_INVALIDATE OR RDW_ALLCHILDREN? "??????????????????????????? --- ?? - ????????????????????? Handle? RGN (refresh partial screen) 6. Windows instructions in DOS under the CLS instructions!? Paintdesktop (getdc (0)); 7. Extend control new function? ? In the programming, we often control the action of the control, but the control does not provide this method ?? At this time, you can give the control to this control to achieve our goal! ?? Such as: ????? Button1 .Perform (WM_KeyDown, 13, 0); ????? ListBox1.Perform (WM_VScroll, SB_LINEDOWN, 0); ??, etc. Can you go to overload !!!!! 8. Flashing title such as printer Timeout (one) FORM put a Timer control ??????? TIME event? ??????????? ?? FlashWindow (Application.handle, True); 9. Add a VCL control on the desktop! (not painted, can not refresh)? Windows.SetParent (control .handle, 0); Note: What do you want to do? ( Such as 'start status bar') 10. About? 'Similar MDI mode new solution (one line !!!!)' correction? Windows.SetParent (Self.handle, 'to set to Mainform's Form'); 11 ordinary The Form Implied MDI is always at the bottom of the bottom ??????? setActiveWindow (0); ?? or? SetWindowPos (...); 12 Perform the following statement to start the Windows screen saver ?? SendMessage (hwnd_broadcast, wm_syscommand, sc_screensave , 0); 13 Button Caption Multi-Bank Display: ?? setWindowlong (Button1.Handle, GWL_Style, ????????????????? GetWindowlong (Button1.Handle, GWL_Style) Or ??? ?????????????????????? bs_multiline); ?? If necessary, add button1.invalidate; 14. Why is ASM INT $ 19 END? Q: How to change the ListBox font? Modify one of the rows.

A: ListBox1.Style first set and then write the following code to lbOwnerDrawFixed procedure TForm1.ListBox1DrawItem at OnDrawItem event (Control: TWinControl; Index: Integer; Rect:? TRect; State: TOwnerDrawState); var Offset:? Integer; begin? OFFSET: = 2;? With (control as tlistbox) .canvas do beg ?? FillRect (Rect); ?? if index = 2 THEN BEGIN ???? font.name: = 'fixedsys'; ???? font. COLOR: = CLRED; ???? font.size: = 12; ?? Else begin ???? font.name: = 'arial'; ???? font.color: = CLBLACK; ???? font .Size: = 8; ?? end; ?? if odselected in state dam ???? font.color: = CLWHITE; ?? End; ?? Textout (Rect.Left Offset, Rect.top, (Control As TListBox) .Items [index]) ;? End; end; Q: How to insert a picture in Richedit? A: Please come here to see the answer http://www.undu.com/articles/991107c.html Q: How can I be able to directory? A: I am coming. Uses shellapi; propedure deletefiles (Source: string); var? fo: tshfileopstruct; begin? Fillchar (fo, sizeof (fo), # 0) ;? fo.d: = form1.handle ;? fo.wfunc: = fo_delete; Fo.pfrom: = pchar (SOURCE); SHFILEOPERATION (FO); End; Procedure EmptyDirectory (path: string); begin ??? if DirectoryExists (path) THEN??? Degin ???????? deletefiles (PATH '/ *'); ??? End ??? Else ??????? forcedirectories (path); end; Q: How to map network drives? For example, I want to map File: // Server / Sys to F.

I need a function such as file: // server / sys / home / bruno to my return value f: / home / bruno a: Function UNCODRIVE (UNCPATH: STRING): STRING; var? Drivenum: Integer ; Drivechar: char ;? drivebits: set of 0..25 ;? StartStr, Teststr: string; begin? Result: = uncpath ;? startstr: = uncpath ;? integer (drivebits): = getLogicalDrives;? For drousum: = 0 TO 25 DO? Begin ??? IF (Drivenum In Drivebits) The begin ????? Drivechar: = Char (Drivenum ORD ('A')); ????? Teststr: = ExpanduncFileName (DriveChar ": / '); ????? if teststr <>' 'THEN ??????? IF POS (Uppercase (Teststr), Uppercase (StartStr))> 0 THEN ????????? begin ????????????? delete (StartStr, 1, Length (Teststr)); ?????????????? = Drivechar ': /' startstr ;? ???????????????????? Break; ??????????? End; ??????? End ;? end; end; Q: I have some special language fonts Use, they are stored in my EXE file, but two points. ?? * I don't want to put it in the font folder ?? * I don't want to extract it from the exe file. If possible, please tell me. Because my font is not what I do, I want to protect my own things. A: It is unlikely to be extracted. You can use this protection process to protect your files that are not modified and deleted. Place the font in the temporary folder when Exe is executed, and delete it at the end.

Function protectfile (sfilename: string): hfile; var ?????? HF: HFILE; ?????? lwhfilesize, lwfilesize: longword; ?????? ofs: Tofstruct; begin ?????? If FileExists (sfilename) THEN ?????? begin ?????????????? HF: = OpenFile (Pchar (sfilename), OFS, OF_READ or OF_WRITE or OFS, OF_EAD OR OF JRITE OF_SHARE_EXCLUSIVE); ???? ?????????? IF HF <> 0 THEN ???????????????????????????????????????????? ??? lwfilesize: = getFileSize (hf, @LWHFILESIZE); ?????????????????????????? f f (HF, 0, 0, LWFILESIZE, LWHFILESIZE) THEN ?????????????????????? result: = HF else result: = 0; ?????????????? End???? ??????????? Else Result: = 0; ?????? End ?????? Else Result: = 0; end; //..var?ress: TRESOURCESTREAM; TEMPPATH : Array [0..max_path] of char;? Tempdir: string; begin? getTemppath (SizeOf (Temppath), Temppath) ;? Tempdir: = strpas (path) ;? RRE: = TRESOURSTREAM.CREATE (Hinstance, 'Some_Font' , 'RT_FONT') ;? ResS.SavetoFile (TempDir 'some_font.ttf') ;? ResS.Free;? AddFontResource (TempDir 'some_font.ttf') ;? SendMessage (HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;? ProtectFile ( TEM PDIR 'SOME_FONT.TTTF'); END; Q: How to get the current Programfiles path? A: You can do it with the method of reading and writing. Code is as follows: uses registry; procedure TForm1.Button1Click (Sender: TObject); var reg: TRegistry; begin reg:?? = TRegistry.Create; reg.RootKey:?? = HKEY_LOCAL_MACHINE; if reg.OpenKey ( 'SOFTWARE / Microsoft / Windows / currentversion ', false) THEN? Begin ?? Edit1.text: = reg.readstring (' programfilesdir '); ?? reg.closekey; ?? reg.free; end; end; q: How to be on the JPG image Write word? A: There is a code here.

hmm, here's a sample with help of Bitmap, you can chance the brush style of canvas to bsClear to make the text transparent uses Jpeg; procedure TForm1.Button1Click? (Sender: TObject); var Bmp:? TBitmap; Jpg:? TJpegImage; Begin? try ?? bmp: = tbitmap.create; ?? jpg: = tjpegimage.create; ?? jpg.loadFromfile ('c: /img.jpg'); ?? bmp.assign (jpg); ?? BMP. Canvas.brush.Style: = bsclear; ?? bmp.canvas.font.color: = CLYELLOW; ?? bmp.canvas.textout (10, 10, 'hello world'); ?? jpg.assign (bmp);? ? Jpg.savetofile ('c: /img2.jpg') ;? finally ?? bmp.free; ?? jpg.free; end; end; q: How to modify the file with Delphi? Under Windows, there are three days, create, modify, and store in the properties.

How can I change it? A: Here is the excerpt from the Jedi Code Library If it is not complete then get the JCL type // indicates the file time to set, used by SetFileTimesHelper and SetDirTimesHelper TFileTimes = (ftLastAccess, ftLastWrite, ftCreation); function..?? SetFileTimesHelper (const FileName: string; const DateTime: TDateTime; Times: TFileTimes): Boolean; var Handle:? THandle; FileTime:? TFileTime; SystemTime:? TSystemTime; begin Result:?? = False; Handle: = CreateFile (PChar ( ? FileName), GENERIC_WRITE, FILE_SHARE_READ, nil, ?? OPEN_EXISTING, 0, 0) ;? if Handle <> INVALID_HANDLE_VALUE then try ?? //SysUtils.DateTimeToSystemTime(DateTimeToLocalDateTime(DateTime), SystemTime); ?? SysUtils.DateTimeToSystemTime (DateTime , Systemtime); ?? if windows.systemTIMETOFILETIME (SystemTime, filetime) Then ?? begin ???? case Times of ?????? ftlastaccess: ??????? Result: = setFileTime (Handle, NIL) @Filetime, nil); ?????? ftlastwrite: ???????? result: = setfiletime (handle, nil, nil, @filetime); ?????? ftcreation: ???? ???? result: = setFileTim e (Handle, @filetime, nil, nil); ???? end; ?? end;? finally ?? closehandle (Handle); end; end; // ------------ -------------------------------------------------- ------------------------------------ Function SetFileLastAccess (Const DateTime: TDATETIME): Boolean; begin? Result: = setfiletimeeshelper (filename, datetime, ftlastaccess); end; // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- ------------------ Function setFileLaseTwrite (const datetime: tdatetime): boolean; begin? result: = setFileTimeShelper (filename, datetime, ftlastwrite); end;

/ / -------------------------------------------------------------------------------------------- -------------------------------------------------- function SetFileCreation (const FileName: string; const DateTime: TDateTime): Boolean; begin Result:? = SetFileTimesHelper (FileName, DateTime, ftCreation); end; about delphi too URL on google: http://directory.google.com/ Top / Computers / Programming / Languages ​​/ Delphi /? tc = exe file procedure TForm1.FormClose about delphi have their own URL http://dir.yahoo.com/Computers_and_Internet/Programming_and_Development/Languages/Delphi/ delete the program on 1 yahoo ( Sender: Tobject; var? F: textfile; begin? Assignfile (f, 'delself.bat') ;? Rewrite (f); {f is textFile type}? Writeln (f, 'del' ExtractFileName (Application.exename)) ;? Writeln (f, 'del% 0'); ?? // Delete yourself DELSELF.BAT? CloseFile (f) ;? Winexec ('delself.bat', sw_hide); end; if ORD (S [9])> 128 THEN? ShowMessage ('This location character is Chinese characters'); Chinese characters are double-bytes of change system time format: var? str: string; begin? str: =' YYYY-MM-DD ';? if setlocaleInfoa (locale_system_default, local_slongdate, pchar (str)) THEN? SHOWMESAGE (' Change Date Format Success') ;? EN D; END; take a minute: vari: integer; begin? i: = gettickcount ;? while (gettickcount-i) <= 10000 do ??? Application.processMessages; // guarantee the message loop END;? Take the host file name: Function RetuFileName (const filename: string): string; var? i: integer; begin? i: = lastdelimiter ('.', filename) ;? Result: = Copy (FileName, 1, I-1); end;?? (1). A event after the Ctrl and other keys are pressed.

??? Procedure TFORM1.FORMKEYDOWN (Sender: Tobject; var key: word; ???? shift: tshiftstate); ??? begin ????? if (key = 67) THEN? ??????? ShowMessage ('KeyDown Ctrl C'); ??? End; (2). During the Tab button in. ?? Procedure TFORM1.DBGRID1KEYPRESS (Sender: Tobject; Var Key: char ); ?? begin ???? if key = # 13 Then ???? if ActiveControl = dbgrid1 Then ???? begin ??????? TdbGrid (ActiveControl) .SelectedIndIndex: = TDBGRID (ActiveControl) .SelectedIndex .selected 1; ??????? key: = # 0; ???? End; ?? end; (3). Dabrid Select a multi-line event. ??? procedure tform1.button1click (sender: TOBJECT); ??? var ??? i: integer; ??? BookmarkList: tbookmarklist; ??? Bookmark: tbookmarkstr; ??? begin ????? Bookmark: = AdoQuery1.bookmark; ????? BookmarkList: = dbgrid1.selectedRows; ????? Try ????? begin ??????? for i: = 0 to BookmarkList.count-1 do ??? ???? begin ????????? adoQuery1.bookmark: = BookmarkList [i]; ?????????? ?????? begin ???? ??????? edit; ??????????? FieldByname ('mdg'). asstring: = edit2.text; ??????????? post; ??? ?????? end; ??????? end; ????? end; ????? finally ????? adoQuery1.bookmark: = BOOKMARK; ????? End ;? ?? end; (4). A appearance effect of form. ??? procedure tform1.button1click (sender: TOBJECT); ??? var ??? r: thandle; ??? i: integer; ??? begin ????? for i: = 1 to trunc (width / 1.414) Do ????? begin ??????? R: = CreatellipticRgn (Trunc (Width / 2) -i, Trunc (Height / 2) i, Trunc ( HEIGHT / 2) I); ??????? setwindowrgn (Handle, R, True); ??????? Application.ProcessMessages; ??????? Sleep (1);??? ?? End; ??? End; (5). With Enter instead of Tab moves in the edit box.

??? Procedure TFORM1.FORMKEYPRESS (Sender: Tobject; var key: char); ??? begin ????? if key = # 13 Then ??????? begin ????????? If not (activeControl is TMEMO) THEN ????????? begin ??????????? key: = # 0; ??????????? KEYBD_EVENT (VK_TAB, MapVirtualKey (VK_TAB, 0), 0, 0); ????????? End; ??????? end; ??? end; (6) .Progressbar plus color. ??? const ??? {$ externalsym PBS_MARQUEE} ??? PBS_MARQUEE = 08; ??? var ????? Form1: tForm1; ??? IMPLEMENTATION ??? {$ r * .dfm} ??? Uses ??? urctrl; ??? procedure tform1.button1click (sender: Tobject); ??? begin ????? // set the background color to Teal ????? progressbar1.brush.color: = CLTEAL;? ????? // set bar color to Yellow ????? SendMessage (ProgressBar1.Handle, PBM_setBarcolor, 0, ClyEllow); ??? End; (7). Edit box color when moving points.

??? procedure tform1.edit1enter (sender: TOBJECT); ??? begin ????? (sender: = CLRED; ??? End; ??? procedure tform1.edit1exit (sender: Tobject) "??? begin ????? (SENDER: = CLWHITE; ??? End; (8). Backup and recovery ??? procedure tForm1.button1click (sender: Tobject); ??? begin ????? if OpenDialog1.execute the ????? begin ??????? Try ????????? adoConnection1.connected: = false; ????????? adoconnection1 .Connectionstring: = 'provider = sqloledb.1; persist security info = false; user ID = sa; initial catalog = master; data source = friend-yofzksco;' ????????? 'USE Procedure for prepare = 1; Auto Translate = True; Packet Size = 4096; Workstation ID = FRIEND-YOFZKSCO; Use Encryption for Data = False; Tag with column collation when possible = False '; ????????? adoconnection1.Connected: = True; ????????? with adoquery1 do ????????? begin ??????????? close; ??????????? SQL .Clear; ??????????? SQL.Add ('backup Database Sfa to disk =' ' opendialog1.filename ' ''); ??????????? EXECSQL ; ?????????? End; ??????? EXCEPT ????????? ShowMessage ('±? · yê§ ° ü');? ?????? EXIT; ??????? End; ????? end; ????? Application.MessageBox ('1 §? 2? Ú? Êy? Y ±? · Y3é1 | ',' ìáê? ', MB_OK MB_ICONITIONFORMATION; ??? End; ??? procedure tform1.button2click (sender: Tobject); ??? begin ????? if openiteog1.execute thr ??????? Try ????????? adoconnection1.connected: = false; ????????? adoConnection1.connectionstring: = 'provider = sqloledb.1; persist security info = false User ID = sa; initial catalog = master; data source = friend-yofzksco; ' ?????????' use procedure for prepare = 1; auto translate = true; packet size = 4096;

Workstation id = friend-yofzksco; use encryption for data = false; tag with column collation when possible = false '; ????????? adoconnection1.connected: = true; ????????? with Adoquery1 do ????????? begin ??????????? close; ?????????? sql.clear; ?????????? ? Sql.add ('restore database sfa from disk =' '' OpenDialog1.filename '' '); ??????????? EXECSQL; ???????? end;?? ???? eXcept ???????? ShowMessage ('???' ê§ ° ü '); ???????? EXIT; ?????? end;?? ??? ; ???? Application.MessageBox ('1 §? 2? Ú? Êy? Y ???' 3 é1 | ',' ìáê? ', MB_OK MB_ICONITIONFORMATION; ??? End; (9). Find LAN The SQL Server servement. ??? uses comobj; ??? procedure tform1.button1click (sender: Tobject); ??? variant; ??? serverlist: variant; ??? i, nservers: integer; ??? SretValue : String; ??? begin ????? SQLServer: = createoleObject ('sqldmo.application'); ????? ServerList: = SQLSERVER.ListavailableSqlServers; ????? Nservers: = ServerList.count; ?? ??? for i: = 1 to nservers do ????? listbox1.items.add (serverList.Item (i)); ????? SQLServer: = null; ????? serverlist: = null; ??? End; (10). The fade in the form is open. ??? procedure tform1.formcreate (sender: TOBJECT); ??? begin ????? AnimateWindow (Handle, 400, aw_center); ??? End; (11). Dynamically create a form. ??? procedure tform1.button1click (sender: TOBJECT); ??? begin ????? Try ??????? form2: = tForm2.create (self); ??????? form2.showModal ; ????? finally ??????? form2.free; ????? end; ??? End; ??? procedure tFORM1.FORMCLOSE (Sender: Tobject; var Action: tclosection); ?? ? begin ????? action: = cafree; ??? End; ??? procedure tForm1.FormDestroy (sender: TOBJECT); ??? begin ????? form1: = nil; ??? End; 12). Copy the file.

??? procedure tform1.button1click (sender: Tobject); ??? begin ????? Try ????? CopyFilea (PCHAR ('C: /AAA.TXT'), PCHAR ('D: / AAA. TXT '), FALSE); ????? EXCEPT ????? ShowMessage (' sfdsdf '); ????? End; ??? End; (13). Copy the folder. ??? uses shellapi; ??? procedure tform1.button1click (sender: Tobject); ??? var ?????? lpfileop: Tshfileopstruct; ??? begin ????? with lpfileop do ????? Begin ??????? wnd: = self.handle; ??????? wfunc: = fo_copy; ??????? PFROM: = PCHAR ('c: / aaa');??? ???? pto: = pchar ('d: / aaa'); ??????? fflags: = fof_allowundo; ??????? hnamemappings: = nil; ??????? lpszprogressTitle: = NIL; ??????? fanyopertonsaborted: = true; ???? end; ???? if shfileOperation (lpfileop) <> 0 THEN ???? ShowMessage ('Delete Failed "; ??? End (14). Change the selected color of DBGRID. ??? Procedure TFORM1.DBGRID1DRAWDATACELL (Sender: TObject; const: TRECT; ??? Field: tfield; state: tgriddrawstate); ??? begin ????? f gdselected in state then ???? setbkcolor DBGRID1.CANVAS.HANDLE, CLGREEN) ????? Else ????? setbkcolor (dbgrid1.canvas.handle, clwhite); ????? dbgrid1.canvas.textRect (Rect, 0, 0, Field.Asstring ); ????? dbgrid1.canvas.textOut (Rect.LEFT, Rect.top, Field.Asstring); ??? End; (15). Detecting the system has installed ADO.

??? uses registry; ??? function tform1.adoinStalled: boolean; ??? var ??? r: Tregistry; ??? s: string; ??? begin ????? r: = Tregistry.create; ????? Try ????? begin ??????? rootkey: = HKEY_CLASS_ROOT; ??????? Openkey ('/adodb.connection/curver ", False); ??????? s: = readstring (''); ??????? f? ??????? Else Result: = FALSE ??????? closekey; ???????????? finally; ????? end; ??? end; ??? procedure tFORM1. Button1Click (Sender: TOBJECT); ??? begin ???? if AdoinStalled The showMessage ('this computer has installed ado "); ??? end; (16). The IP address of the peeling host. ??? uses winso; ??? procedure tform1.button1click (sender: TOBJECT); ??? var ??? ip: string; ??? ipstr: string; ??? buffer: array [1..32] of Char; ??? i: integer; ??? wsdata: twsadata; ??? Host: phostent; ??? begin ????? if wsastartup (2, wsdata) <> 0 THEN ???? begin? ?????? ShowMessage ('ws2_32.dll3? ê ?? ˉˉ§ ° ü.'); ??????? EXIT; ????? end; ????? Try ???? ??? if gethostname (@Buffer [1], 32) <> 0 THEN ??????? begin ????????? ShowMessage ('?? ódμ? μ ?? ÷? ú ?? . '); ??????? EXIT; ????? End; ????? eXcept ??????? ShowMessage (' ?? ód3é1 | · μ ??? ÷? ú ?? '); ??????? EXIT; ????? end; ????? Host: = gethostByname (@Buffer [1]); ????? if Host = nil the ???? ? begin ??????? ShowMessage ('IPμ ??????. "); ??????? EXIT; ????? end ????? ELSE ????? Begin ??????? edit2.text: = host.h_name; ??????? edit3.text: = chr (Host.h_addrtype 64); ??????? for i: = 1 To 4 do ??????? begin ???????? IP: = INTTOSTR (ORD (Host (Host.h_ADDR ^ [i-1])); ???????? IF i <4 THEN ???????? ipstr: = IPSTR IP '.' ??????? Else ???????? edit1.text: = IPSTR IP; ??????? End; ?????? End; ?????? wsacleanup; ??? end; (17). A computer name.

??? Function TFORM1.GET_NAME: STRING; ??? var? computename: pchar ;? size: dword; ??? begin ??????? getmem (computername, 255); ??????? size : = 255; ??????? if getcomputername (computername, size) = false then ?????????? result: = '' ??????? ELSE ?????? ???? result: = computername; ??????? freemem (computername); ??? end; ??? procedure tform1.button1click (sender: TOBJECT); ??? begin ????? label1. CAPTION: = GET_NAME; ??? End; (18). A hard disk serial number. ??? function tform1.gethdserialnumber: longint; ??? {$ IFDEF WIN32} ??? var ????? PDW: pdword; ????? mc, fl: dword; ??? {$ ENDIF}? ?? begin ????? {$ IFDEF WIN32} ????? new (PDW); ????? getVolumeInformation ('C: /', NIL, 0, PDW, MC, FL, NIL, 0) ; ????? result: = PDW ^; ????? dispose (PDW); ???? {$ else} ????? result: = getwinflags; ????? {$ ENDIF}? ?? End; ??? procedure tForm1.button1click (sender: TOBJECT); ??? begin ????? edit1.text: = INTOSTR (GETHDSERIALNUMBER); ??? End; (19). Limit the cursor mobile range. ??? procedure tform1.button1click (sender: TOBJECT); ??? var ??? Rect1: TRECT; ??? begin ????? RECT1: = Button2.BoundSRect; ????? MapWindowPoints (Handle, 0 , Rect1, 2); ????? clipcursor (@ Rect1); ??? End; ??? procedure tform1.button2click (sender: TOBJECT); ??? var ??? screenRect: TRECT; ??? Begin ????? screenRect: = Rect (0, 0, screen.width, screen.height); ????? clipcursor (@screenRect); ??? End; (20). Restricting the EDIT box can only enter numbers . ??? procedure tform1.edit1keypress (Sender: Tobject; var key: char); ??? begin ????? if not (key in ['0' .. '9', '.', # 8]) THEN ????? begin ??????? key: = # 0; ??????? messagebeep (0); ????? end; ??? end; (21) .dbgrid Call in a certain color according to any condition.

??? procedure TForm_main.DBGridEh1DrawColumnCell (Sender: TObject; ??? const Rect: TRect; DataCol: Integer; Column: TColumnEh; ??? State: TGridDrawState); ??? begin ????? if (trim (DataModule1 .AdoQuery1.fieldbyname ('dczt'). Asstring) = 'ok') Then ????? begin ??????? if Datacol = 6 THEN ?????? begin ?????? ??? dbgrideh1.canvas.brush.color: = CLGRADIENTACTIVECAPTION; ????????? DBGRIDEH1.DEFAULTDRAWCOLUMNCELL (Rect, Datacol, Column, State); ??????? End; ????? End; ??? End; (22). Open the word file. ??? procedure tfjfsglform.speedbutton4click (sender: TOBJECT); ??? Var ??? msword: variant; ??? str: string; ??? begin ????? if Trim (DataModule1.adoQuery27.fieldbyname (' FJMC '). asstring) <>' 'Then ????? begin ??????? Str: = trim (DataModule1.adoQuery27.fieldbyName (' fjmc '). asstring); ??????? Msword: = CreateoleObject ('Word.Application'); // ??????? Msword.Documents.Open ('D: / Program Files / Common Files / SFA /' STR, TRUE); // ?? ????? msword.visible: = 1; // ??????? Str: = ''; ??????? msword.activedocument.range (0, 0); //??? ???? msword.activedocument.range.insertafter (str); //? Úword? D ??? ó × ?? 'Title' ??????? msword.activedocument.range.insertparagraphafter; ??? ?? END ????? Else ????? ShowMessage (''); ??? End; (23) .word file incoming and outgoing database.

??? uses idglobal; ??? procedure tdjhyform.speedButton2Click (sender: TOBJECT); ??? var ??? sfilename: string; ??? function blobconTostString (const filename: string): string; ??? begin ?? ???? with tfilestream.create (filename, fmopenread)? do ????? Try ?????? setlength (result, size); ??????? read (Pointer (Result) ^, SIZE ); ????? finally; ????? end; ??????? begin ????? if openDialog1.execute life ????? begin? ?????? sfilename: = OPENDIALOG1.FILENAME; ??????? DataModule1.adoquery14.edit; ??????? DataModule1.adoquery14.fieldByname ('Word'). asstring: = blobcontentTostring (sfilename ); ??????? DataModule1.adoQuery14.post; ????? end; ??? end; ??? procedure tdjhyform.speedbutton1click (sender: TOBJECT); ??? var ??? sfilename: string ; ??? bs: tadoblobstream; ??? begin ????? bs: = tadoblobstream.create (TBLOBFIELD (DataModule1.adoQuery14.fieldbyname ('Word')), bmread); ????? Try ??? ???? sfilename: = extractFilePath (Application.exename) Trim (DataModule1.adoQuery14.fieldbyName ('Hybh'). asstring); ??????? sfilename: = sfilename '.' 'DOC' ; ??????? bs.savetofile (sfilename); ????????? DJHYOpenForm: = tdjhyopenform.create (Self); ???????? DJHYOPENFORM.OLECONTAINER1.CREATEOBJECTFROMFILE (sfilename, false); ????????? DJHYOPENFORM.OLECONTAINER1.ICONIC: = true; ????????? DJHYOPENFORM.SHOWMODAL; ??????? Finally ????????? DJHYOpenForm.Free; ?????????????? bs.free; ????? end; ??? End; (24). Tips for the Chinese title. ??? procedure TdjhyForm.SpeedButton5Click (Sender: TObject); ??? begin ????? if Application.MessageBox ( '', Mb_YesNo Mb_IconWarning) = Id_yes then DataModule1.ADOQuery14.Delete; ??? end; (25 ) Run an application file.

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

New Post(0)