Win32 Common Code collation

Source: Internet
Author: User

1, ShellExecute "Use Shellapi"

' Open ' ' http://www.cnblogs.com/lovelp/ ' Nil Nil, sw_show);

2, about the path

Expandfilename () returns the full path of the file (with drive, path)  
Extractfileext () extracts the extension from the file name Span class= "Apple-converted-space" > 
Extractfilename () extracts a file name without a path from the file name  
Extractfilepath () Extract path name from file name Extractfiledir () extracts the directory name from the file name  
Extractfiledrive () Extract the drive name from the file name  
Changefileext () to change the file name extension  
Expanduncfilename () returns the full path of the file containing the network drive  
Extractrelativepath () extracts relative path information from the file name  
Extractshortpathname () Convert file names to DOS 8 3 format  
Matchesmask () checks if the file matches the specified file name format

3 common ways to get the current path:

Extractfilepath (Paramstr (0'\';

3, the format of time

FormatDateTime ('yyyy-mm-dd', Now ());


4. Extracting Time components

Yearofmonthofweekofdayofhourofminuteofsecondof

5. INI operation

varInifile:tinifile; //Creating ObjectsInifile:=tinifile.create (inifilepath+inifilename);//Read DataInifile.readstring (' Section','Key','DefaultValue')//stringInifile.readinteger (' Section','Key', DefaultValue);//integer  //Write DataInifile.writestring (' Section','Key','Value')//stringInifile.writeinteger (' Section','Key', tValue);//Releasing ObjectsInifile.free;//If you want to read the entire value, you can use Inifile.readsection (' sectionname ', stringlist) to read the whole piece of data into the Tstringlist object

6. Read and write the registration form "Use Registry"

procedureTform1.button1click (sender:tobject);varReg:tregistry;beginReg:=tregistry.create;//Create an instanceReg. Rootkey:=hkey_current_user;//Specify the primary key for the registry that needs to be manipulated  if(Reg. Openkey ('Software\dsy', true)) Then  beginReg. WriteString ('Fishname','Freshwater Fish');//writes a string type, or it can be another typeReg.  Closekey; End; Reg. Free;End;procedureTform1.button2click (sender:tobject);varReg:tregistry;beginReg:=tregistry.create;//Create an instanceReg. Rootkey:=hkey_current_user;//Specify the primary key for the registry that needs to be manipulated  if(Reg. Openkey ('Software\dsy', true)) Then  beginShowMessage (Reg. ReadString ('Fishname'));//read the registration formReg.  Closekey; End; Reg. Free;End;
View Code

Win32 Common Code collation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.