#include <stdio.h> #include <string.h> #include <stdlib.h> #include <afx.h> #define MODULESUM 30 char *GetKeyPos(const char *szBuffer, const char *szKey) { // ASSERT(szBuffer && szKey); if (*szKey == '/0') { return NULL; } while(*szBuffer) { if (strnicmp(szBuffer, szKey, strlen(szKey)) == 0) { return (char*)szBuffer; } szBuffer++; } return NULL; } long GetSpecifyValue(const char *szBuffer, const char *szKey) { int nValue = -1; char *pVaulePos = NULL; char *pKeyPos = GetKeyPos(szBuffer, szKey); if (pKeyPos!=NULL) { pVaulePos = pKeyPos + strlen(szKey) + 1; nValue = atol(pVaulePos); } return nValue; } int main() { char szRlt[] = "LogonRlt=1;modulecnt=10;21=0,20=0,19=1,18=0,17=1,16=0,15=1,13=0,12=1,11=0"; int nCnt = 0; int nLastModule[MODULESUM] = {0}; int nModule[MODULESUM] = {-1}; char szTmp[10] = {0}; printf("&&&&&&&&&&&&&&&&&&&&&&&&&/n"); for (int i=0; i<MODULESUM; ++i) { nModule[i]=-1; } nCnt = GetSpecifyValue(szRlt, "modulecnt"); printf("%d/n", nCnt); for (/*int*/ i=0; i<MODULESUM; ++i) { nLastModule[i] = 1; if (i<=10) { continue; } itoa(i, szTmp, 10); nModule[i] = GetSpecifyValue(szRlt, szTmp); } printf("*************************/n"); for (int j=0; j<MODULESUM; ++j) { printf("%d/n", nModule[j]); } printf("*************************/n"); CString strRlt="OrderMode=1&moduleid="; bool bFirst = false; CString strTmp; for (i=0; i<MODULESUM; ++i) { if (i<=10) { continue; } if (nModule[i]==0 && nModule[i]!=nLastModule[i] && nModule[i]!=-1) { if (i==11) { bFirst = true; } if(!bFirst) { strRlt += ","; } bFirst = false; strTmp.Format("%d",i); strRlt += strTmp; } } MessageBox(NULL, strRlt, NULL, 0); getchar(); return 0; }