zoukankan      html  css  js  c++  java
  • VC:INI文件中节与健的枚举(GetPrivateProfileSection()、GetPrivateProfileSectionNames())

    //先选择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()

    {

          

           //2、节与健的枚举

    /*    1 健

                  DWORD GetPrivateProfileSection(

                    LPCTSTR lpAppName,        // section name

                    LPTSTR lpReturnedString,  // return buffer

                    DWORD nSize,              // size of return buffer

                    LPCTSTR lpFileName        // initialization file name

                  );

           2 节

                  DWORD GetPrivateProfileSectionNames(

                    LPTSTR lpszReturnBuffer,  // return buffer

                    DWORD nSize,              // size of return buffer

                    LPCTSTR lpFileName        // initialization file name

                  );

    */

           int i;

           int pos=0;

           //CString str;

           char chSectionNames[MAX_ALLSECTIONS]={0};//总的提出来的字符串

           char chSection[MAX_SECTION]={0};//存放一个小节名

           char chKey[MAX_SECTION]={0};

           //LPCTSTER lpFileName="";

           GetPrivateProfileSectionNames(chSectionNames,MAX_ALLSECTIONS,lpFileName);

                  //cout<<chSectionNames<<endl;

           for(i=0;i<MAX_ALLSECTIONS-1;i++)

           {

                  /*

                  if(chSectionNames[i]==0 && chSectionNames[i+1]!=0)//得到前面段明

                  {

                         for(int m=pos;m<=i;m++)

                         {

                                chSection[m-pos]=chSectionNames[m];//获取小节名

                         }

                         pos=i+1;

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

                         cout<<str<<endl;

                  }

                  if(chSectionNames[i]==0&&chSectionNames[i+1]==0)//得到最后一个小节名

                  {

                         for(int m=pos;m<=i;m++)

                         {

                                chSection[m-pos]=chSectionNames[m];

                         }

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

                         cout<<str<<endl;

                         break;

                  }*/

                  if(chSectionNames[i]==0)//得到前面段明

                  {

                         for(int m=pos;m<=i;m++)

                         {

                                chSection[m-pos]=chSectionNames[m];//获取小节名

                         }

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

                         cout<<str<<endl;

                         //获取键值

                         GetPrivateProfileSection(chSection,chKey,MAX_SECTION,lpFileName);

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

                         cout<<str<<endl;

                         if(chSectionNames[i+1]!=0)

                         {

                                pos=i+1;

                         }

                         else

                         {

                                break;

                         }

          

                  }

           }

    }

  • 相关阅读:
    Odoo many2many command
    odoo-cn 邮件列表
    教育 管理系统
    ddmrp
    odoo12新特性: 会计改进
    odoo分析会计
    Odoo 8,9,10 制造领料、入库 实践
    Odoo 后端数据库postgreSQL事务级别
    Hive建表与导入文件中的数据
    Hadoop编写一键集群全起start-cluster.sh、全关stop-cluster.sh、显示所有jps进程show-jps.sh脚本 以及群起zookeeper服务,jps不显示的解决方案
  • 原文地址:https://www.cnblogs.com/shenchao/p/2737762.html
Copyright © 2011-2022 走看看