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;

                         }

          

                  }

           }

    }

  • 相关阅读:
    Request和Session的生命周期
    了解EBP指针
    esp跟ebp跟踪记录
    深入浅出Node.js (6)
    洛谷 P2404 自然数的拆分问题
    洛谷 P1852 奇怪的字符串
    洛谷 P1433 吃奶酪
    洛谷 P1881 绳子对折
    洛谷 P1162 填涂颜色
    P1145 约瑟夫
  • 原文地址:https://www.cnblogs.com/shenchao/p/2737762.html
Copyright © 2011-2022 走看看