zoukankan      html  css  js  c++  java
  • VC:INI文件中键名数据的读写(GetPrivateProfileString())

    //先选择Project|setting命令下Project setting命令下对话框,在Microsoft Foundation Classes下选择 Use MFC in a Shared DLL

    #include<iostream.h>

    #include<afx.h>

    //#include<afx1.h>

    #define MAX_ALLSECTIONS 300  //定义最大的段长度

    #define MAX_SECTION 20     //段的最大长度

    void main()

    {

           //1、键名数据的读写

    /*    1

                  UINT GetProfileInt(

                  LPCTSTR lpszSection,

                  LPCTSTR lpszEntry,

                  int nDefault );

           2

           UINT GetPrivateProfileInt(

           LPCTSTR lpAppName,  // section name

           LPCTSTR lpKeyName,  // key name

           INT nDefault,       // return value if key name not found

           LPCTSTR lpFileName  // initialization file name

           );

           3

                  DWORD GetPrivateProfileString(

                    LPCTSTR lpAppName,        // section name

                    LPCTSTR lpKeyName,        // key name

                    LPCTSTR lpDefault,        // default string

                    LPTSTR lpReturnedString,  // destination buffer

                    DWORD nSize,              // size of destination buffer

                    LPCTSTR lpFileName        // initialization file name

                  );

           4

                  BOOL WritePrivateProfileString(

                    LPCTSTR lpAppName,  // section name

                    LPCTSTR lpKeyName,  // key name

                    LPCTSTR lpString,   // string to add

                    LPCTSTR lpFileName  // initialization file

                  );

    */

           LPCTSTR lpFileName="C:\\test.ini";

           CString str;

           char c[10];

           WritePrivateProfileString("SECTION_1","Key1","test1",lpFileName);

           WritePrivateProfileString("SECTION_2","Key2","test2",lpFileName);

           GetPrivateProfileString("SECTION_1","Key1","error",c,10,lpFileName);

           str.Format("%s",c);

           cout<<str<<endl;

    }

  • 相关阅读:
    Windows下安装使用OpenLDAP
    LDAP安装配置(windows)
    LDAP概念和原理介绍
    JDK自带的keytool证书工具详解
    递归算法讲解
    Creating an archive from a directory without the directory name being added to the archive
    Overview of the M&A Process
    Make sure base method gets called in C#
    How to delete specific nodes from an XElement?
    如何学习数据结构?
  • 原文地址:https://www.cnblogs.com/shenchao/p/2737759.html
Copyright © 2011-2022 走看看