赞
踩
- #include "string.h"
- #include <vector>
-
- void CAutoZipDlg::OnBnClickedOk()
- {
- using namespace std;
- vector<CString> strVec;
-
- CString teststr = GetCommandLine(); //retrives the command-line string for the current process.
- CString outputstr;
- int flag = 0;
-
- for(int i = 0;i < teststr.GetLength(); i++)
- {
- if(teststr[i]=='\"')
- {
- ++flag;
-
- }
- else if(flag == 2)
- {
- //MessageBox(outputstr, "outputstr");
- strVec.push_back(outputstr);
- outputstr = "";
- flag = 0;
- }
- else if(teststr[i]==' ' && flag == 0)
- {
- //MessageBox(outputstr, "outputstr");
- strVec.push_back(outputstr);
- outputstr = "";
-
- }
- else
- {
- outputstr += teststr[i];
- }
- }
-
- if(outputstr.GetLength()>0)
- {
- //MessageBox(outputstr, "outputstr");
- strVec.push_back(outputstr);
- }
-
- for(vector<CString>::const_iterator it = strVec.begin()+1;it != strVec.end();it++)
- {
- //TRACE(*it);
- //TRACE("\n");
- MessageBox(*it, "文件路径");
- }
- }
对命令行字符串的处理,方法之一。刚入门不久,希望今后可以改进!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。