MFC tenth day (Files & registry)

Source: Internet
Author: User

(Struggling to sink)

Before the content was eaten, too lazy to fill

MFC operations on files:

File Operation class Constructor: CFile (file name, shared access mode);

Common class Method: Write writes data; Read reads data; Seek moves pointer position, seektobegin pointer start point, seektoend pointer moves end, GetLength gets file length

File write: Get Object > class method writes write (content, length) > class method Close

File read: Get object > Get length > Construct buffer based on length +1, and last byte assignment 0> class method reads read (cache, length) > Close

  file Dialog Class construction : CFileDialog (dialog box type selection (true-> Open Dialog;false-> Save dialog box), set default extension, set default initial name

dialog box settings, set filter, specify parent window), after five items have default values

Save As dialog box: Construct Class object CFileDialog Filedlg (FALSE) > Display dialog Box Fildlg.domodal ();

Open File dialog box: Construct Class object CFileDialog Filedlg (TRUE) > Show dialog Box Fildlg.domodal ();

dialog box configuration: Title: FileDlg.m_ofn.lpstrTitle = "my title";

Filter: FileDlg.m_ofn.lpstrFilter = "Text File (*.txt) \0*.txt\0all Files (*. *) \0*.*\0\0"; Format: text description \ \ \ \ \ \ \ Can repeat multiple groups \0\0 two to end

Default extension: fileDlg.m_ofn.lpstrDefExt = "txt";

Get full path: Filedlg.getpathname ()

Get file name: Filedlg.getfilename ()

Registry access:

Create key: None is set to start; RegCreateKey (select Table item handle (registry branch), table name, return handle to store);

Close key: RegCreateKey (); close handle

Open key: RegOpenKey (table item handle, table name, handle stored);

Write table: RegSetValue (table item handle, table name, table value type, table value, table value length); (recommended)

RegSetValueEx (table item handle, table name, 0, table value type, table value cache, table value length)

Read table: RegQueryValue (table item handle, table name, return value cache, return value length)

RegQueryValueEx ()

  

MFC tenth day (Files & registry)

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.