[00022]-[2015-09-19]-[00]-[windows Platform Basics 0]

Source: Internet
Author: User
Tags readfile

[related actions of files]
[createfile]//Open or create a file

HANDLE CreateFile (lpctstr lpfilename,//file nameDWORD dwDesiredAccess,//the access mode of the file generic_read| Generic_writeDWORD dwShareMode,//shared mode for filesLpsecurity_attributes lpSecurityAttributes,//the security attribute of the file NULLDWORD Dwcreationdispositon,//how file creation is handled ....DWORD dwFlagsAndAttributes,//flags and attributes at file creation File_attribute_normalHANDLE hTemplateFile//file Template NULL);

[CloseHandle]//File use end Close file handle to free resources

BOOL CloseHandle (HANDLE hobject);     // Handle to File

[DeleteFile]//delete files

BOOL DeleteFile (LPCTSTR lpfilename);     // file name

[ReadFile]//file read

BOOL ReadFile (    HANDLE hfile,     / / file handle    lpvoid lpbuffer,     //  Data read buffer    DWORD nnumberofbytestoread,     //  number of data bytes scheduled to read    Lpdword Lpnumberofbytesread,     //  number of data bytes actually read    lpoverlapped lpoverlapped     // NULL);

[WriteFile]//File Write

BOOL WriteFile (    HANDLE hfile,     / / file handle    lpvoid lpbuffer,     //  Data written by buffer    DWORD nnumberofbytestowrite,     //  number of data bytes scheduled to be written    Lpdword Nnumberofbyteswritten,     //  number of data bytes actually written    lpoverlapped lpoverlapped     //  NULL);

[SetFilePointer]//Set file pointer position

DWORD setfilepointer (    HANDLE hfile,     //  file pointer    LONG ldistancetomove,     / /  offset (low)    Plong lpDistanceToMoveHigh,     //  offset (high) pointer type is generally    NULL using only the low offset /c12>    DWORD dwmovemethod     //  datum position file_begin (file start position)     file_current (file current position) File_end ( File end position));

[CreateDirectory]//Create Directory

BOOL createdirectory (    lpctstr lppathname,     //  directory name created    lpsecurity_attributes lpSecurityAttributes    //  NULL);

[RemoveDirectory]//delete directory

BOOL removedirectory (    lpctstr lppathname     //  deleted directory name );


[Basic operation of the process]
[createprocess]//Create strname process

BOOL CreateProcess (LPCTSTR lpapplicationname,//name of the executable fileLPCTSTR lpCommandLine,//run parameters for the executable file NULLLpsecurity_attributes Lpprocessattributes,//Process Security Property NULLLpsecurity_attribytes Lpthreadattributes,//Thread-Safe Properties NULLBOOL bInheritHandle,//whether an inheritable handle in the current process can be inherited by a new processDWORD dwCreationFlags,//priority and creation flags for new processes//debug_process The parent process can debug a child process (a new process) and its child processes//debug_only_this_process The parent process can debug a child process (a new process)//create_suspended Sub-process (new process) is not run immediately after creation (suspended)LPVOID Lpenvironment,//environment variable for new process NULLLPCTSTR Lpcurrentdirectory,//current directory used by the new processLpstartupinfo Lpstartupinfo,//startup information for the new process/*typedef struct _STARTUPINFO {DWORD cb; LPTSTR lpreserved; LPTSTR LpDesktop; LPTSTR lptitle;dword dwx;dword dwy;dword dwxsize;dword dwysize;dword Dwxcountchars;dword DwYCountChars;DWORD Dwfillattribute;dword DwFlags; WORD Wshowwindow; WORD CbReserved2; Lpbyte LpReserved2; HANDLE hStdInput; HANDLE Hstdoutput; HANDLE Hstderror;} Startupinfo, *lpstartupinfo;*/lpprocess_information lpprocessinformation//relevant information parameters for (process and main thread) in the new process/*typedef struct{handle Hprocess,handle Hthread,dword Dwprocessid,dword dwthreadid}process_information, *LPPROCESS _information*/); 

[Egcode]:

 process_information pi = {0  }; Startupinfo si  = {0  };SI.CB  = sizeof   (STARTUPINFO); BOOL BRet  = CreateProcess ( c:\\1.exe   , NULL, NU                 LL, NULL, FALSE, NULL, NULL, NULL,  &si,  &pi); //  If you don't want to consume too much system resources You can close the handle of the process and the main thread after the process is created to release the handle resource  closehandle (Pi.hthread); CloseHandle (pi.hprocess);  

[OpenProcess]//Open DWPROCESSID process

HANDLE openprocess (process_all_access, FALSE, Dwprocessid);

[ExitProcess]//Normal exit process

[TerminateProcess]//Force Quit process

[CloseHandle]//close process handle when it does not mean that the shutdown process simply frees the "process handle" resource (the handle is also one of the system resources)

[00022]-[2015-09-19]-[00]-[windows Platform Basics 0]

Related Article

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.