Delphi Basic Development Skills
◇ [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 / CurrentVersion SystemRoot 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.ins ERT (1, 'Insert String At No 2 Line'); Tips.Savetofile ('newfile.txt'); Tips.Free; ◇ [Delphi] Simple clipboard 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 current Directory name, no '/' getdir (0, s); // Take the work directory name s: = 'c: / abcdir'; deleetfile ('abc.txt'); // Delete file renamefile ('old.txt' , 'new.txt'); // file rename extractFileName (fileListBox1.FileName); // Take the file name extractFileExt (fileEListBox1.FileName); // Take a file suffix ◇ [Delphi] Process file attribute attr: = filegetttr (FileListbox1. FileName);
IF (attr and fareadonly = fareadonly kil1 ... // read-only if (attr and fasysfile) = FasysFile kil1 ... // system if (attr and fixive) = faarchive dam // archive IF (Attr and Fahidden) = Fahidden Ten ... // Hide ◇ [Delphi] Export Output 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); ◇ [SZText: array [0..254] of char; begin hcurrentwindow: = getWindow (HcURRENTWINDWDFRIST); WHILINDOW (HcURRENTWINDOW <> 0 do begin if Getwindowtext (hcurrnetwindow, @ sztext, 255)> 0 then listbox1.items.add (strpas (@sztext)); hCurrentWindow: = Getwindow (hCurrentwindow, GW_HWndNext); end; end; ◇ [DELPHI] on the compilation of Embed an ASM end; can be arbitrarily modified ESI, ECX, EBP, EBX, and EBX cannot be modified. ◇ [Delphi] About Type Conversion Function FLOATTOSTR / / Floating Stroke Floattostrf // Floating Point Run Strings INTTOHEX // Integer Transfer 16 Enter TimeTStr DateTostr DateTimetostr FMTSTR DATSTR DATIMETOSTR FMTSTR DATOSTR DATIMETOSTR FMTSTR DATOSTR DATIMETOSTR FMTSTSTR DATOTSTIMETIMETIME FORMATDATDATIME FORMATDATIME (' 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_DOWN F1 - 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 Cookie Response.cookies ("name") .Domain: = 'http://www.086net.com'; with response.cookies.add do beg, name: = 'username'; value: = 'username'; end ◇ [Delphi ] Added to the 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.rem windows / system / tmmr.rem ◇ [Delphi] Judgment Mouse Buttons If getasynckeyState (vk_lbutton) <> 0 THEN .. . // Left IF getasynckeyState (vk_mbutton) <> 0 THEN ... / / Middle key if getasynckeyState (vk_rbutton) <> 0 the ... // 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) Begin if msg.Message = 256 Then ... // any key if msg.Message = 112 Then ... // f1 if msg.Message = 113 Then ... // f2 end;
◇ [Miscellaneous] hidden 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 effect of web 60 seconds timed Close Close Close timing of forwarding URL ◇ [DELPHI] intercepted WM_QUERYENDSESSION shutdown message type TForm1 = 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); begin Showmessage ( 'computer is about to shut down'); end; ◇ [DELPHI] Get Network neighborhood procedure getnethood ( ); // NT makes the server, WIN98 debugging.
var a, 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 begin dwscope: = 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 begin enumentries: = 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) Do Begin Alldomain.Add (Netres [A ] .lpremotename; a: = a 1; end; wnetcloseenum (enumHandle); // Get all computers mylistitems: = controlCenter.lstComputer.Items; mylistitems.clear; for i: = 0 to alldomain.count-1 do begin with netres [0] do begin dwscope: = 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, ResourceUsage_Container, @ NetRes [0], ENUMHANDLE); if Errcode = NO_ERROR THEN BEGIN ENUMENTRIES: = 1024;
Buffersize: = SizeOf (Netres); Errcode: = WnerRcode: = WnerRcode: @ NetRes [0], Buffersize); End; A: = 0; while (netres [a] .lpprovider <> ') and (errcode = NO_ERROR) do begin mylistitem: = mylistitems.Add; mylistitem.ImageIndex: = 0; mylistitem.Caption: = uppercase (stringreplace (string (NetRes [a] .lpremotename), '//', '', [rfReplaceAll ])); A: = a 1; end; wnetcloseenum (enumHandle); end; end; ◇ [delphi] Gets shared directory procedure getsharefolder (consT computername: string) on a computer; Var errcode, A: integer; netres: array [0..1023] of netresource; enumhandle: thandle; enumentries, buffersize: dword; s: string; mylistitems: tlistitems; mylistitem: tlistitem; mystrings: tstringlist; begin with netres [0] do begin dwscope: = 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, Resourceus AGE_CONTAINER, @ netres [0], enumhandle); if errcode = NO_ERROR then begin EnumEntries: = 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) do begin with mylistitems do Begin MyListItem: = add; mylistInditem.imageIndex: = 4; MyListItem.caption: = extractFileName (NetRes [a] .lpremotename); end; a: = a 1; end; end; ◇ [delphi] get hard disk serial number VAR Serialnum: PDWORD; A, B: DWORD;
Buffer: Array [0..255] of char; beginiff getvolumeinformation ('c: /', buffer, sizeof (buffer), serialnum, a, b, nil, 0) Then label1.caption: = INTOSTR (Serialnum ^) ; end; ◇ [DELPHI] MEMO automatic page turning 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'); end on page //; procedure TForm1.Button1Click (Sender: TObject); begin ScrollMemo (Memo1 , 'u'); // Turn the page end; ◇ [Delphi] DBGRID Enter to the next position (Tab Key) Procedure TFORM1.DBGRID1KEYPRESS (Sender: Tobject; var key: char); begin if key = # 13 Then if dbgrid1.columns.grid.selectedIndIndex
◇ [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 (Sourcem Emo.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 (Diskchar: char): String; var Serialnum: pdword; A, B: DWORD; Buffer: array [0. .255] OF Char; Begin Result: = ""; 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 sheet 3. Embed a style sheet 4. // Inline style Arial // SPAN Accept Style, Class, and ID Properties DIV can include paragraphs, titles, tables, and even other portions 5. Class attribute // Definition See 3. 6. ID attribute // Definition See 3. 7. Property list font style: font-style: [Normal | Italic | Oblique]; font size: font-size: [xx-small | x-small | small | Medium | Large | X-Large | XX-Large | Larger | Smaller |
Length unit relative units: EM (EM, element font) EX (X-height, letter "x" height) PX (pixel, resolution relative to the screen) absolute length: in (inch, 1 inch = 2.54 Cm) cm (cm, 1 cm = 10 mm) mm (m) PT (point, 1 point = 1/72 inches) PC (Pa, 1 Pa = 12 points) ◇ [Delphi] VCL production brief steps 1. Create parts Attribute method events (establish library units, inherited to new types, add attributes, methods, events, registration parts, build package files) 2. Message processing 3. Exception processing 4. Parts Visual ◇ [Delphi] Dynamic connection library loading Static loading: procedure name; external 'lib.dll'; dynamic loading: var handle: thandle; handle: = loadingLibrary ('lib.dll'); if Handle <> 0 Then Begin {DOSMETHING} Freelibrary (HANDLE); ◇ [Delphi] pointer variable and address var x, y: integer; p: ^ integer; // pointing to the integer variable pointer x: = 10; // Variable assignment P: = @ x; // Variable X address Y: = P ^; / / For Y assignment pointer p @@ procedure // Return to the memory address of the process variable ◇ [Delphi] Judgment character is a character of the Chinese characters bytetype ('Hello Haha', 1) = MBLEADBYTE / / is the first A character bytetype ('Hello Haha', 2) = MBTRAILBYTE / / is the second character bytetype ('Hello Haha', 5) = MBSINGLEBYTE / / is not Chinese characters ◇ [Delphi] MEMO positioning operation MEMO1 .lines.delete (0) // Delete the first line memo1.selstart: = 10 / / Positioning 10 bytes ◇ [Delphi] Get double-byte characters Function Getit (s: string): Integer; Begin Result: = BYTE (s [1]) * $ 100 byte (s [2]); end; use: getit (') // $ BCC6, 10 refine 48326 ◇ [Delphi] calling the add data stored procedure stored procedure as follows: Create Procedure AddRecord (Record1 Varcha R (10) Record2 Varchar (20)) AS Begin Insert Into Tablename (Field1, Field2) VALUES (: Record1,: Record2) End Performs Store: Execute Procedure AddRecord ("UrRecord1", "Urrecord2") ◇ [Delphi] save the file to the blob field function blobcontenttostring (const filename: string): string; begin with tfilestream.create (filename, fmopenread) do try setlength (Result, size); read (Pointer (Result) ^, size); finally free; end; end; // save field begin if (opendialog1.execute) then begin sFileName: = OpenDialog1.FileName; adotable1.edit; adotable1.fieldbyname ( 'visio') asstring:. = Blobcontenttostring (FileName); adotable1.post; end ;
◇ [DELPHI] All the files are copied to the clipboard uses shlobj, activex, clipbrd; procedure Tform1.copytoclipbrd (var FileName: string); var FE: TFormatEtc; Medium: TStgMedium; dropfiles: PDropFiles; pFile: PChar; begin FE.cfFormat : = CF_HDROP; FE.dwAspect: = DVASPECT_CONTENT; FE.tymed: = TYMED_HGLOBAL; Medium.hGlobal: = GlobalAlloc (GMEM_SHARE or GMEM_ZEROINIT, SizeOf (TDropFiles) length (FileName) 1); if Medium.hGlobal <> 0 then begin Medium.tymed: = TYMED_HGLOBAL; dropfiles: = GlobalLock (Medium.hGlobal); try dropfiles ^ .pfiles: = SizeOf (TDropFiles); dropfiles ^ .fwide: = False; longint (pFile): = longint (dropfiles) SizeOf (TDropFiles); StrPCopy (pFile, FileName); Inc (pFile, Length (FileName) 1); pFile ^: = # 0; finally GlobalUnlock (Medium.hGlobal); end; Clipboard.SetAsHandle (CF_HDROP, Medium.hGlobal) ; end; end; ◇ [DELPHI] include the currently running process uses TLHelp32; procedure TForm1.Button1Click (Sender: TObject); var lppe: TProcessEntry32; found: boolean; Hand: THandle; begin Hand: = CreateToolhelp32Snapshot (TH32CS_SNAPALL, 0) Found: = process32first (ha ND, LPPE); While Found Do Begin ListBox1.items.Add (StrPas (LPPE.SZEXEFILE)); Found: = Process32Next (Hand, LPPE); End; End; ◇ [Delphi] Create a new table table table2 table2: = TTable.Create (nil); try Table2.DatabaseName: = Table1.DatabaseName; Table2.FieldDefs.Assign (Table1.FieldDefs); Table2.IndexDefs.Assign (Table1.IndexDefs); Table2.TableName: = 'new_table'; Table2. CreateTable (); finally table2.free (); end; ◇ [delphi] Most food understanding DLL establishment and reference // see DLL SOURCE (File -> New -> DLL) Library Project1; Uses Sysutils, Classes; Function Addit (f: integer; s: integer; eng); begin makeasum: = f s; End; Exports Addit;
End. // Call (in Ur Project) Implementation Function Addit (f: Integer; S: Integer): Integer; Far; External 'Project1'; // Declining {Call is Addit (2, 4); Result Show 6} ◇ [Delphi] Dynamic Reader Self-size Function Gesselfsize: Integer; var f: file of byte; begin filemode: = 0; assignfile (f, application.exename); reset (f); result: = filesis (f); / / Unit is byte closefile (f); end; ◇ [delphi] read BIOS information with memo1.lines do begin add ('mainboardbiosname:' ^ i string (PCHAR (Ptr (Ptr (Ptr ($ FE061)))); add ('MainboardBioscopyright:' ^ i string (PCHAR (PTR ($ FE091)))))); add ('mainboardbiosdate:' ^ i string (PCHAR (Ptr (PTR (PTR ($ FFFF5))))); add ('MainboardBiosserialno: ' ^ I string (PCHAR (PTR ($ FEC71)))))); END; ◇ [delphi] dynamically established MSSQL alias Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); var mylist: tstringlist; begin mylist: = TSTRINGLIST.CREATE Try with mylist do begin add ('server name = 210.242.86.2'); add ('database name = db'); add ('user name = sa'); end; session1.addalias ('testsql', 'MSSQL ', Mylist); // ミ mssql session1.saveconfigfile; Finally MyList.Free; session1.active: = true; Database1.DATABA SENAME: = 'DB'; Database1.aliasName: = 'Testsql'; Database1.LoginPrompt: = FALSE; Database1.Params.Add ('user name = sa'); Database1.Params.Add ('password ='); Database1 .Connected: = true; end; end; procedure tForm1.button2click (sender: TOBJECT); begin database1.connected: = false; session1.deletealias ('testsql');? Span class = "u4"> o? Span class = "u4"> w end; ◇ [Delphi] Play background music USES mmsystem // Play music MCISENDSTRING ('Open E: /1.MID TYPE SEQUENCER Alias NN', '', 0, 0); MCISENDSTRING ('Play nn from 0 ','
', 0, 0); McIndString (' Close Animation ',' ', 0, 0); End; // Stop Play McIndString (' Open E: /1.MID TYPE SEQUENCER Alias NN ',', 0, 0 ); McISendString ('Stop NN', '', 0, 0); McISendString ('Close Animation', '', 0, 0); ◇ [Delphi] interface and class code type code type code type code {interface and class declaration: The difference is that it is not possible to declare data members in the interface, any non-public method, public method does not use public keyword} isample = interface // Define ISAMPLE interface Function GetString: String; end; tsample = class (TinterFaceDObject, isample) Public function GetString : string; end; // function definition function tsample.getstring: string; begin result: = 'What show is'; end; // call class object var Sample: tsample; begin sample; showMessage; SAMPLE.Create; showMESAGE. GetString 'Class Object!'); Sample.Free; End; // Call Interface VAR SampleInterface: Isample; Sample: Tsample; Begin Sample: = Tsample.create; SampleInterface: = Sample; // Interface Implementation must use Class { Two lines can also be forms a samples: = tsample.create;} showMessage (SampleInterface.getstring 'interface!'); //Sample.free; {and local class different, Interface automatic release} SampleInterface: = nil; { Release the interface object} end; ◇ [Delphi] task bar to see the program VAR ExtendedStyle: Integer; Begin Appli cation.Initialize; ExtendedStyle: = GetWindowLong (Application.Handle, GWL_EXSTYLE); SetWindowLong (Application.Handle, GWL_EXSTYLE, ExtendedStyle OR WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW); Application.CreateForm (TForm1, Form1); Application.Run; end ◇ [DELPHI. ] ALT CTRL DEL can not see the program adds a statement after the implementation: function RegisterServiceProcess (dwProcessID, dwType: Integer): Integer; stdcall; external 'KERNEL32.DLL'; RegisterServiceProcess (GetCurrentProcessID, 1); // hide RegisterServiceProcess (GetCurrentProcessID , 0); // Display ◇ [Delphi] Detects CD-ROM Symbol VAR Drive: Char; CDROMID: Integer; Begin for Drive: = 'D'
To 'Z' Do Begin CDRomid: = GetDriveType (Pchar (Drive ': /')); if CDRomid = 5 Then ShowMessage ('Your CD-ROM:' Drive 'disk!'); end; end; ◇ [Delphi ] detecting sound if auxGetNumDevs () <= 0 then showmessage ( 'No soundcard found!') else showmessage ( 'Any soundcard found!'); ◇ [DELPHI] Paint StringGrid.OnDrawCell event string grid with StringGrid1.Canvas DO DRAW (Rect.Pict, Rect.top, Image1.Picture.graphic); Select * from table1 where username Like '% C% "Next is another way to complete the above features: Use myDatabase select * from table1 where charIndex (' c ', username)> 0 This method is theoretically than the previous method There is a judgment statement, that is,> 0, but this judgment process is the fastest, I want to believe that more than 80% of the operations are spending a string and other operations, so it is not very much in use with the charIndex function. This approach is also good, that is, to%, | It can also be written: Use mydatabase select * from table1 where charindex (char (37), username)> 0 ASCII characters are% ◇ [Delphi] SQL displays multi-database / table Select Distinct A.Bianhao, A.XINGMING, B. Gongzi from "jianjie.dbf" a, "gongzi.dbf" b w Here a.bianhao = B.Bianhao ◇ [Delphi] RFC (Internet Engineering Task Force) Maintenance RFC Document http://www.ietf.cnri.reston.va.us rfc882: packet header structure RFC1521: MIME first portion, packet transmission methods RFC1945: multimedia document transfer document ◇ [DELPHI] TNMUUProcessor use var inStream, outStream: TFileStream; begin inStream: = TFileStream.create (infile.txt, fmOpenRead); outStream: = TFileStream (outfile.txt, fmCreate); NMUUE.Method: = uuCode; {UUEncode / Decode} //NMUUE.Method:=uuMIME;{MIME} NMUUE.InputStream: = InStream; NMUUE.OutputStream: = OutStream; NMUUE.Encode; {Encoding process} //nmuue.decode; {decoding processing} instream.free; outstream.free; end;