MFC文件操作大全

来源:互联网 发布:编程学习网 编辑:程序博客网 时间:2024/05/20 07:31
1.创建文件夹 
CreateDirectory(%%1,NULL); 

2.创建文件 
CFile file;  
file.Open(%%1,CFile::modeCreate|CFile::modeWrite);  

3.删除文件 
DeleteFile(%%1);  

4.删除文件夹 
RemoveDirectory(%%1);  

5.删除一个目录下所有的文件夹 
CFileFind finder;  
BOOL bWorking = finder.FindFile(%%1+"\\*.*");  
while (bWorking) 

bWorking = finder.FindNextFile(); 
if (finder.IsDirectory()) 

dir.Delete(finder.GetFilePath()); 

}  

6.清空文件夹 
RemoveDirectory(%%1); 
CreateDirectory(%%1,NULL)  

7.读取文件 
char sRead[1024]; 
CFile mFile(_T(%%1),CFile::modeRead); 
while (sRead!=null) 

mFile.Read(sRead,1024); 
CString %%2=CString(sRead); 
%%3 
}  

8.写入文件 
CFile mFile(_T(%%1), CFile::modeWrite|CFile::modeCreate); 
mFile.Write(%%2,sizeof(%%2)); 
mFile.Flush(); 
mFile.Close();  

9.写入随机文件 
char szTempPath[_MAX_PATH],szTempfile[_MAX_PATH]; 
GetTempPath(_MAX_PATH, szTempPath); 
GetTempFileName(szTempPath,_T ("my_"),0,szTempfile); 
CFile m_tempFile(szTempfile,CFile:: modeCreate|CFile:: modeWrite); 
char m_char='a'; 
m_tempFile.Write(&m_char,2); 
m_tempFile.Close(); 
//循环写入多个值 
strTempA; 
int i; 
int nCount=6; 
//共有6个文件名需要保存 
for (i=0;i{strTemp.Format("%d",i); 
strTempA=文件名; 
//文件名可以从数组,列表框等处取得. 
::WritePrivateProfileString("UseFileName","FileName"+strTemp,strTempA, 
c:\\usefile\\usefile.ini); 

strTemp.Format("%d",nCount); 
::WritePrivateProfileString("FileCount","Count",strTemp,"c:\\usefile\\usefile.ini"); 
//将文件总数写入,以便读出. 
//读出 
nCount=::GetPrivateProfileInt("FileCount","Count",0,"c:\\usefile\\usefile.ini"); 
for(i=0;i{strTemp.Format("%d",i); 
strTemp="FileName"+strTemp; 
::GetPrivateProfileString("CurrentIni",strTemp,"default.fil", strTempA.GetBuffer(MAX_PATH),MAX_PATH,"c:\\usefile\\usefile.ini"); 
//使用strTempA中的内容. 
}  

10.读取文件属性 
dwAttrs = GetFileAttributes(%%1);  
if (dwAttrs & FILE_ATTRIBUTE_READONLY) {  
 %%2 
}  
if (NORMAL & FILE_ATTRIBUTE_READONLY){  
 %%3 
}  

11.写入属性 
SetFileAttributes(szNewPath,dwAttrs | FILE_ATTRIBUTE_READONLY);  

12.枚举一个文件夹中的所有文件夹 
CFileFind finder;  
BOOL bWorking = finder.FindFile(%%1+"\\*.*");  
while (bWorking) {  
bWorking = finder.FindNextFile(); 
if(finder.IsDirectory()){ 
CString %%1=finder.GetFilePath(); 
%%2 

}
13.复制文件夹 
WIN32_FIND_DATA FileData;  
HANDLE hSearch;  
DWORD dwAttrs;  
char szDirPath[] = %%2;  
char szNewPath[MAX_PATH];  
char szHome[MAX_PATH];  
BOOL fFinished = FALSE;  
if (!CreateDirectory(szDirPath, NULL)) { 
//不能创建新的目录  
 return; 

hSearch = FindFirstFile(%%1+"\\*.*", &FileData);  
if (hSearch == INVALID_HANDLE_VALUE) {  
 return;  
}  
while (!fFinished) {  
 lstrcpy(szNewPath, szDirPath);  
 lstrcat(szNewPath, FileData.cFileName);  
 if (CopyFile(FileData.cFileName, szNewPath, FALSE)) {  
 dwAttrs = GetFileAttributes(FileData.cFileName);  
 if (!(dwAttrs & FILE_ATTRIBUTE_READONLY)) {  
 SetFileAttributes(szNewPath,  
 dwAttrs | FILE_ATTRIBUTE_READONLY);  
 }  
 }  
 else {  
 //不能复制文件 
 return;  
 }  
 if (!FindNextFile(hSearch, &FileData)) {  
 if (GetLastError() == ERROR_NO_MORE_FILES) {  
 //遍历文件夹完成  
 fFinished = TRUE;  
 }  
 else {  
 //找不到下一个文件 
 return;  
 }  
 }  
}  
FindClose(hSearch);  

14.复制一个文件夹下所有的文件夹到另一个文件夹下 
WIN32_FIND_DATA FileData;  
HANDLE hSearch;  
DWORD dwAttrs;  
char szDirPath[] = %%2;  
char szNewPath[MAX_PATH];  
char szHome[MAX_PATH];  
BOOL fFinished = FALSE;  
if (!CreateDirectory(szDirPath,NULL))  

//不能创建新的目录  
return; 

BOOL bWorking = finder.FindFile(%%1+"\\*.*");  
while (bWorking)  
{  
bWorking = finder.FindNextFile(); 
if(finder.IsDirectory()){ 
hSearch = FindFirstFile(finder.GetFilePath()+"\\*.*", &FileData);  
if (hSearch == INVALID_HANDLE_VALUE)  
{  
return;  
}  
while (!fFinished)  
{  
lstrcpy(szNewPath, szDirPath);  
lstrcat(szNewPath, FileData.cFileName);  
if (CopyFile(FileData.cFileName, szNewPath, FALSE))  
{  
dwAttrs = GetFileAttributes(FileData.cFileName);  
if (!(dwAttrs & FILE_ATTRIBUTE_READONLY))  
{  
SetFileAttributes(szNewPath,  
dwAttrs | FILE_ATTRIBUTE_READONLY);  
}  
}  
else  
{  
//不能复制文件 
return;  
}  
if (!FindNextFile(hSearch, &FileData))  
{  
if (GetLastError() == ERROR_NO_MORE_FILES)  
{  
//遍历文件夹完成  
fFinished = TRUE;  
}  
else  
{  
//找不到下一个文件 
return;  
}  
}  
}  
FindClose(hSearch); 

}
15.移动文件夹 
WIN32_FIND_DATA FileData;  
HANDLE hSearch;  
DWORD dwAttrs;  
char szDirPath[] = %%2;  
char szNewPath[MAX_PATH];  
char szHome[MAX_PATH];  
BOOL fFinished = FALSE;  
if (!CreateDirectory(szDirPath, NULL))  

//不能创建新的目录  
return; 

hSearch = FindFirstFile(%%1+"\\*.*", &FileData);  
if (hSearch == INVALID_HANDLE_VALUE)  
{  
return;  
}  
while (!fFinished)  
{  
lstrcpy(szNewPath, szDirPath);  
lstrcat(szNewPath, FileData.cFileName);  
if (CopyFile(FileData.cFileName, szNewPath, FALSE))  
{  
dwAttrs = GetFileAttributes(FileData.cFileName);  
if (!(dwAttrs & FILE_ATTRIBUTE_READONLY))  
{  
SetFileAttributes(szNewPath,  
dwAttrs | FILE_ATTRIBUTE_READONLY);  
}  
}  
else  
{  
//不能复制文件 
return;  
}  
if (!FindNextFile(hSearch, &FileData))  
{  
if (GetLastError() == ERROR_NO_MORE_FILES)  
{  
//遍历文件夹完成  
fFinished = TRUE;  
}  
else  
{  
//找不到下一个文件 
return;  
}  
}  
}  
FindClose(hSearch);  
RemoveDirectory(%%1);
16.移动一个文件夹下所有的文件夹到另一个目录下 
WIN32_FIND_DATA FileData;  
HANDLE hSearch;  
DWORD dwAttrs;  
char szDirPath[] = %%2;  
char szNewPath[MAX_PATH];  
char szHome[MAX_PATH];  
BOOL fFinished = FALSE;  
if (!CreateDirectory(szDirPath,NULL))  

//不能创建新的目录  
return; 

BOOL bWorking = finder.FindFile(%%1+"\\*.*");  
while (bWorking)  
{  
bWorking = finder.FindNextFile(); 
if(finder.IsDirectory()){ 
hSearch = FindFirstFile(finder.GetFilePath()+"\\*.*", &FileData);  
if (hSearch == INVALID_HANDLE_VALUE)  
{  
return;  
}  
while (!fFinished)  
{  
lstrcpy(szNewPath, szDirPath);  
lstrcat(szNewPath, FileData.cFileName);  
if (CopyFile(FileData.cFileName, szNewPath, FALSE))  
{  
dwAttrs = GetFileAttributes(FileData.cFileName);  
if (!(dwAttrs & FILE_ATTRIBUTE_READONLY))  
{  
SetFileAttributes(szNewPath,  
dwAttrs | FILE_ATTRIBUTE_READONLY);  
}  
}  
else  
{  
//不能复制文件 
return;  
}  
if (!FindNextFile(hSearch, &FileData))  
{  
if (GetLastError() == ERROR_NO_MORE_FILES)  
{  
//遍历文件夹完成  
fFinished = TRUE;  
}  
else  
{  
//找不到下一个文件 
return;  
}  
}  
}  
FindClose(hSearch); 
RemoveDirectory(finder.GetFilePath().GetBuffer(0)); 

}  

17.以一个文件夹的框架在另一个目录创建文件夹和空文件 
WIN32_FIND_DATA FileData;  
HANDLE hSearch;  
DWORD dwAttrs;  
char szDirPath[] = %%2;  
char szNewPath[MAX_PATH];  
char szHome[MAX_PATH];  
BOOL fFinished = FALSE;  
if (!CreateDirectory(szDirPath, NULL))  

//不能创建新的目录  
return; 

hSearch = FindFirstFile(%%1+"\\*.*", &FileData);  
if (hSearch == INVALID_HANDLE_VALUE)  
{  
return;  
}  
while (!fFinished)  
{  
lstrcpy(szNewPath, szDirPath);  
lstrcat(szNewPath, FileData.cFileName);  
HANDLE hFile=CreateFileHandle hFile=CreateFile(szNewPath,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN,NULL); 
if(!hFile) 
{  
//不能创建文件 
return;  
}  
if (!FindNextFile(hSearch, &FileData))  
{  
if (GetLastError() == ERROR_NO_MORE_FILES)  
{  
//遍历文件夹完成  
fFinished = TRUE;  
}  
else  
{  
//找不到下一个文件 
return;  
}  
}  
}  
FindClose(hSearch);  

18.复制文件 
CopyFile(%%1,%%2,true)

19.复制一个文件夹下所有的文件到另一个目录 
//#include <string> 
using std::string; 
char sep='/'; 
#ifdef _WIN32 
sep='\\'; 
#endif 
CFileFind finder;  
BOOL bWorking = finder.FindFile(%%1+"\\*.*");  
while (bWorking)  
{  
bWorking = finder.FindNextFile(); 
if(!finder.IsDirectory() || finder.IsDots()){ 
string s(finder.GetFileName()); 
CString sourcefile(%%1); 
if(s.rfind(sep,s.length())!=string::npos) 

sourcefile=sourcefile+"//"+s.substr(i+1,s.length()-i); 
CString targetfile(s.substr(i+1,s.length()-i)); 
targetfile=%%2+"//"+targetfile/; 
CopyFile(sourcefile.GetBuffer(0),targetfile.GetBuffer(0),true); 


}  

20.提取扩展名 
//#include <string> 
using std::string; 
string s(%%1); 
size_t i=s.rfind('.',s.length()); 
if(i!=string::npos) 
CString %%2(s.substr(i+1,s.length()-i)); 
else 
CString %%2="";  

21.提取文件名 
//#include <string> 
using std::string; 
string s(%%1); 
char sep='/'; 
#ifdef _WIN32 
sep='\\'; 
#endif 
size_t i=s.rfind(sep,s.length()); 
if(i!=string::npos) 
CString %%2(s.substr(i+1,s.length()-i)); 
else 
CString %%2="";  
/* 
CString path(%%1); 
CString %%2=path.Mid(path.ReverseFind('\\')+1); 
*/ 

22.提取文件路径 
//#include <string> 
using std::string; 
string s(%%1); 
char sep='/'; 
#ifdef _WIN32 
sep='\\'; 
#endif 
size_t i=s.rfind(sep,s.length()); 
if(i!=string::npos) 
CString %%2(s.substr(0,i)); 
else 
CString %%2="";  
/* 
char appName[MAX_PATH]; 
GetModualFileName(NULL,appName,MAX_PATH); 
*/

23.替换扩展名 
//#include <string> 
using std::string; 
string s(%%1); 
string newExt(%%2); 
string::size_type i=s.rfind('.',s.length()); 
if(i!=string::npos) 
s.replace(i+1,newExt.length(),newExt); 
CString %%3(s);  

24.追加路径 
/* 
#include <string> 
#include <cstdlib> 
#include <boost/filesystem/operations.hpp> 
#include <boost/filesystem/fstream.hpp> 
*/ 
using namespace std; 
using namespace boost::filesystem; 
try { 
path p1=complete(path(%%2,native), 
path(%%1,native)); 
path p2=system_complete(path(%%2,native)); 
CString %%3(p3); 

catch(exception& e){ 
//e.what(); 
}  

25.移动文件 
MoveFile(%%1,%%2);  

26.移动一个文件夹下所有文件到另一个目录 
//#include <string> 
using std::string; 
char sep='/'; 
#ifdef _WIN32 
sep='\\'; 
#endif 
CFileFind finder;  
BOOL bWorking = finder.FindFile(%%1+"\\*.*");  
while (bWorking)  
{  
bWorking = finder.FindNextFile(); 
if(!finder.IsDirectory() || finder.IsDots()){ 
string s(finder.GetFileName()); 
CString sourcefile(%%1); 
if(s.rfind(sep,s.length())!=string::npos) 

sourcefile=sourcefile+"//"+s.substr(i+1,s.length()-i); 
CString targetfile(s.substr(i+1,s.length()-i)); 
targetfile=%%2+"//"+targetfile/; 
MoveFile(sourcefile.GetBuffer(0),targetfile.GetBuffer(0),true); 


}  

27.指定目录下搜索文件 
CString strFileTitle; 
CFileFind finder; 
BOOL bWorking = finder.FindFile ("C:\\windows\\sysbkup\\*.cab"); 
while(bWorking) 

bWorking=finder.FindNextFile(); 
strFileTitle=finder.GetFileTitle(); 
}

28.打开对话框 
CFileDialog mFileDlg(TRUE,NULL,NULL, 

OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,"All Files (*.*)|*.*||",AfxGetMainWnd()); 
CString str(" ",10000); 
mFileDlg.m_ofn.lpstrFile=str.GetBuffer(10000); 
str.ReleaseBuffer(); 
POSITION mPos=mFileDlg.GetStartPosition(); 
CString pathName(" ",128); 
CFileStatus status; 
while(mPos!=NULL) 

pathName=mFileDlg.GetNextPathName(mPos); 
CFile::GetStatus( pathName, status ); 
}  

29.文件分割 
CFile m_File; 
CString m_Filename,m_FileTitle,m_FilePath; 
m_FileName=%%1; 
char pBuf[4096]; 
if(m_File.Open(m_FileName,CFile::modeRead | CFile::shareDenyWrite)) 

m_FileName=m_File.GetPathName(); 
m_FileTitle=m_File.GetFileTitle(); 
DWORD FileLength=m_File.GetLength(); 
DWORD PartLength=FileLength/2+FileLength%2; 
int nCount=1; 
CString strName; 
CFile wrFile; 
DWORD ReadBytes; 
while(true) 

ReadBytes=m_File.Read(pBuf,PartLength); 
strName.Format("%s%d",m_FIleTitle,nCount); 
wrFile.Open(strName,CFile::modeWrite | CFile::modeCreate); 
wrFile.Write(pBuf,ReadBytes); 
wrFile.Close(); 
if(ReadBytes<PartLength) 
break; 
nCount++; 

m_File.Close(); 

else 
AfxMessageBox("不能打开文件");

30.文件合并 
//#include <string> 
using std::string; 
string s(%%1); 
char sep='/'; 
#ifdef _WIN32 
sep='\\'; 
#endif 
size_t sz=s.rfind(sep,s.length()); 
if(sz!=string::npos) 

CFile Out; 
CString strFilename(s.substr(i+1,s.length()-i)); 
if(Out.Open(%%2+"//"+strfilename,cfile::modewrite%7ccfile::modecreate)){ 
for(int i=1;i<=2;i++) 

String Filename=%%%2+"//"+strfilename+atoi(i); 
CFile In; 
if(In.Open(Filename,CFile::modeRead)){ 
char cbBuffer[4096]; 
int nFilesize=In.GetLength(); 
while(nFilesize>0){ 
int nSize=sizeof(cbBuffer); 
if(nSize>nFilesize) 
nSize=nFilesize; 
try{ 
In.Read(cbBuffer,nSize); 

catch(CFileException *e){ 
char *lpMsgBuf; 
if(FormatMessage( 
FORMAT_MESSAGE_ALLOCATE_BUFFER | 
FORMAT_MESSAGE_FROM_SYSTEM, 
NULL,e->m_lOsError, 
MAKELANGID(LANG_NEUTRAL, 
SUBLANG_DEFAULT), 
(LPSTR)&lpMsgBuf,0,NULL)>0){ 
AfxMessageBox(lpMsgBuf); 
LocalFree(lpMsgBuf); 

e->Delete(); 
return; 

try{ 
Out.Write(cbBuffer,nSize); 

catch(CFileException *e){ 
char *lpMsgBuf; 
if(FormatMessage( 
FORMAT_MESSAGE_ALLOCATE_BUFFER | 
FORMAT_MESSAGE_FROM_SYSTEM, 
NULL,e->m_lOsError, 
MAKELANGID(LANG_NEUTRAL, 
SUBLANG_DEFAULT), 
(LPSTR)&lpMsgBuf,0,NULL)>0){ 
AfxMessageBox(lpMsgBuf); 
LocalFree(lpMsgBuf); 

e->Delete(); 
return; 

nFilesize=nSize; 


else 
AfxMessageBox("不能打开"+Filename); 


else 
AfxMessageBox("不能创建输出文件"); 
}

31.文件简单加密 
//#include <string> 
using std::string; 
string s(%%1); 
char sep='/'; 
#ifdef _WIN32 
sep='\\'; 
#endif 
size_t sz=s.rfind(sep,s.length()); 
if(sz!=string::npos) 

CFile Out,In; 
int nFIlesize; 
char *lpMsgBuf; 
CString strFilename(s.substr(i+1,s.length()-i)); 
if(!in.Open(%%1,CFile::modeRead)){ 
//不能打开输入文件 
return; 

if(!Out.Open(%%2+"//enc_%22+strfilename,cfile::modewrite/ | CFile::modeCreate)){ 
//不能打开输出文件 
return; 

nFilesize=In.GetLength(); 
lpBuffer=new char[nFilesize]; 
if(lpBuffer==NULL){ 
//不能分配复制缓存 
return; 

CFileStatus rStatus; 
In.GetStatus(%%1,rStatus); 
try{ 
In.Read(cbBuffer,nFilesize); 

catch(CFileException *e){ 
char *lpMsgBuf; 
if(FormatMessage( 
FORMAT_MESSAGE_ALLOCATE_BUFFER | 
FORMAT_MESSAGE_FROM_SYSTEM, 
NULL,e->m_lOsError, 
MAKELANGID(LANG_NEUTRAL, 
SUBLANG_DEFAULT), 
(LPSTR)&lpMsgBuf,0,NULL)>0){ 
AfxMessageBox(lpMsgBuf); 
LocalFree(lpMsgBuf); 

e->Delete(); 
return; 

for(int i=0;i<nFilesize;i++) 

int ibt=lpBuffer[i]; 
ibt+=100; 
ibt%=256; 
bpBuffer[i]=(char)ibt; 

try{ 
Out.Write(cbBuffer,nFilesize); 

catch(CFileException *e){ 
char *lpMsgBuf; 
if(FormatMessage( 
FORMAT_MESSAGE_ALLOCATE_BUFFER | 
FORMAT_MESSAGE_FROM_SYSTEM, 
NULL,e->m_lOsError, 
MAKELANGID(LANG_NEUTRAL, 
SUBLANG_DEFAULT), 
(LPSTR)&lpMsgBuf,0,NULL)>0){ 
AfxMessageBox(lpMsgBuf); 
LocalFree(lpMsgBuf); 

e->Delete(); 
return; 

Out.Close(); 
//In.Close(); 
CFile::SetStatus(%%2+"//enc_%22+strfilename,rstatus); 
 delete[] lpBuffer; 
}  

32.文件简单解密 
//#include <string> 
using std::string; 
string s(%%1); 
char sep='/'; 
#ifdef _WIN32 
sep='\\'; 
#endif 
size_t sz=s.rfind(sep,s.length()); 
if(sz!=string::npos) 

CFile Out,In; 
int nFIlesize; 
char *lpMsgBuf; 
CString strFilename(s.substr(i+1,s.length()-i)); 
if(!in.Open(%%2+"//enc_%22+strfilename,cfile::moderead)){ 
//不能打开输入文件 
return; 

if(!Out.Open(%%1,CFile::modeWrite | CFile::modeCreate)){ 
//不能打开输出文件 
return; 

nFilesize=In.GetLength(); 
lpBuffer=new char[nFilesize]; 
if(lpBuffer==NULL){ 
//不能分配复制缓存 
return; 

CFileStatus rStatus; 
In.GetStatus(%%2+"//enc_%22+strfilename,rstatus); 
 try{ 
In.Read(cbBuffer,nFilesize); 

catch(CFileException *e){ 
char *lpMsgBuf; 
if(FormatMessage( 
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 
NULL,e->m_lOsError, 
MAKELANGID(LANG_NEUTRAL, 
SUBLANG_DEFAULT), 
(LPSTR)&lpMsgBuf,0,NULL)>0){ 
AfxMessageBox(lpMsgBuf); 
LocalFree(lpMsgBuf); 

e->Delete(); 
return; 

for(int i=0;i<nFilesize;i++) 

int ibt=lpBuffer[i]; 
ibt-=100;ibt+=256; 
ibt%=256; 
bpBuffer[i]=(char)ibt; 

try{ 
Out.Write(cbBuffer,nFilesize); 

catch(CFileException *e){ 
char *lpMsgBuf; 
if(FormatMessage( 
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 
NULL,e->m_lOsError, 
MAKELANGID(LANG_NEUTRAL, 
SUBLANG_DEFAULT), 
(LPSTR)&lpMsgBuf,0,NULL)>0){ 
AfxMessageBox(lpMsgBuf); 
LocalFree(lpMsgBuf); 

e->Delete(); 
return; 

Out.Close(); 
//In.Close(); 
CFile::SetStatus(%%1,rStatus); 
delete[] lpBuffer; 
}

33.读取ini文件属性 
CStdioFile inifile(%%1,CFile::modeRead); 
CString path = inifile.GetFilePath(); 
inifile.Close(); 
char key[1024]; 
DWORD bytes = GetPrivateProfileString(%%2,%%3,%%4,key,1024,path); 
if(bytes < 1024) 
key[bytes] = '\0'; 
CString %%5(key);  

34.合并一个文件下所有的文件 
CString Directory=%%1+"*.*"; 
CFileFind FFile; 
CFile Out; 
if(Out.Open(%%2,CFile::modeWrite|CFile::modeCreate)){ 
BOOL bFound=FFile.FindFile(Directory); 
while(bFound) 

bFound=FFile.FileNextFile(); 
if(!FFile.IsDirectory() && !FFile.IsDots()) 

CString Filename=FFile.GetFileName(); 
CFile In; 
if(In.Open(Filename,CFile::modeRead)){ 
char cbBuffer[4096]; 
int nFIlesize=In.GetLength(); 
while(nFIlesize>0){ 

int nSize=sizeof(cbBuffer); 
if(nSize>nFilesize) 
nSize=nFilesize; 
try { 
In.Read(cbBuffer,nSize); 

catch(CFileException *e){ 
char *lpMsgBuf; 
if(FormatMessage( 


FORMAT_MESSAGE_ALLOCATE_BUFFER | 


FORMAT_MESSAGE_FROM_SYSTEM, 
NULL,e->m_lOsError, 
MAKELANGID(LANG_NEUTRAL, 
SUBLANG_DEFAULT), 
(LPSTR)&lpMsgBuf,0,NULL) 

>0){ 
AfxMessageBox(lpMsgBuf); 
LocalFree(lpMsgBuf); 

e->Delete(); 
return; 

try { 
Out.Write(cbBuffer,nSize); 

catch(CFileException *e){ 
char *lpMsgBuf; 
if(FormatMessage( 


FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 
NULL,e->m_lOsError, 
MAKELANGID(LANG_NEUTRAL, 
SUBLANG_DEFAULT), 
(LPSTR)&lpMsgBuf,0,NULL) 

>0){ 
AfxMessageBox(lpMsgBuf); 
LocalFree(lpMsgBuf); 

e->Delete(); 
return; 

nFilesize=nSize; 


else 
AfxMessageBox("不能打开"+Filename); 



else 
AfxMessageBox("不能创建输出文件");

35.写入ini文件属性 
/* 
CStdioFile inifile(%%1,CFile::modeRead); 
CString path = inifile.GetFilePath(); 
inifile.Close(); 
int bytes = GetPrivateProfileInt(%%2,%%3,%%4,path);  
*/ 
WritePrivateProfileString(%%2,%%3,%%4,path); 

36.获得当前路径 
TCHAR szDir[MAX_PATH]; 
GetCurrentDirectory(szDir,MAX_PATH]; 
CString %%1(szDir);  

37.读取XML数据库 
//#include <string> 
//using namespace std; 
char sRead[5192]; 
CFile mFile(_T(%%1),CFile::modeRead); 
mFile.Read(sRead,5192); 
if(sRead!=null) 

string tmp; 
while(sRead!=null) 

tmp.append(sRead); 
mFile.Read(sRead,5192); 

//%%2="Logs" //%%4="ID" //%%6="Content" 
//%%3="Log" //%%5="Time" 
//%%7 code %%8 time %%9 content 
string target(%%7),globalTag("<"+%%2+">"); 
string propTag1("<"+%%5+">",endTag1("</"+%%5+">"); 
string propTag2("<"+%%6+">",endTag1("</"+%%6+">"); 
int offset=tmp.find_first_of(globalTag); 
while(offset) 

offset=tmp.find_first_of(globalTag); 
string description; 
tmp.copy(description.begin(),tmp.find_first_of("\"",offset+1)- 

offset); 
if(target.compare(description)==0) 

string prop,prop2; 
offset=tmp.find_first_of(propTag1,offset)+strlen(%%5)+2; 
tmp.copy(prop.begin(),tmp.find_first_of(endTag1,offset)-  

offset,offset); 
offset=tmp.find_first_of(propTag2,offset)+strlen(%%6)+2; 
tmp.copy(prop2.begin(),tmp.find_first_of(endTag2,offset)-  

offset,offset); 
CString %%8(prop),%%9(prop2); 
%%10 
return 0; 



else 
return -1;

38.写入XML数据库 
//#include <string> 
//using namespace std; 
char sRead[5192]; 
string description; 
CFile mFile(_T(%%1),CFile::modeRead); 
mFile.Read(sRead,5192); 
int no; 
if(sRead!=null) 

string tmp; 
while(sRead!=null) 

tmp.append(sRead); 
mFile.Read(sRead,5192); 

//%%2="Logs" //%%4="ID" //%%6="Content" 
//%%3="Log" //%%5="Time" 
//%%7 code %%8 time %%9 content 
int offset=tmp.find_last_of("<"+%%3+" "+%%4)+strlen(%%3) +strlen(%%4)+4; 
tmp.copy(description.begin(),tmp.find_last_of("\"><"+%%5)-  

offset,offset); 
bo=atoi(description.c_str())+1; 
mFile.Close(); 
tmp.insert(tmp.find_last_of("</"+%%2+">"),"<"+%%3+" "+%%  

4+"=\""+itoa(no)+"\"><"+%%5+">"+%%8+"</"+%%5+"><"+%%6+">"+%%  

9+"</"+%%6+">"); 
CFile file(_T(%%1),CFile::modeWrite); 
file.Write(tmp.c_str()): 
file.Flush(); 
file.Close(); 

else 

CFile file(_T(%%1),CFile::modeWrite|CFile::modeCreate); 
file.Write("<?xml version=\"1.0\" encoding=\"gb2312\"?><"+%%  

2+"><"+%%3+" "+%%4+"=\"0\"><"+%%5+">"+%%8+"</"+%%5+"><"+%%  

6+">"+%%9+"</"+%%6+"></"+%%3+"></"+%%2+">"); 
file.Flush(); 
file.Close(); 
}

39.ZIP压缩文件 
//www.zlib.net 
/* 
#ifdef _DEBUG 
#pragma comment(lib,"zlibd.lib") 
#else 
#pragma comment(lib,"zlib.lib") 
#endif 
#include "zlib.h" 
#include "zconf.h" 
*/ 
HANDLE hFile, hFileToWrite; 
CString strFilePath; 
m_ctrEdit.GetWindowText(strFilePath);  

//打开要进行压缩的文件 
hFile = CreateFile(strFilePath, // file name 
GENERIC_READ, // open for reading 
FILE_SHARE_READ, // share for reading 
NULL, // no security 
OPEN_EXISTING, // existing file only 
FILE_ATTRIBUTE_NORMAL, // normal file 
NULL); // no attr. template  

if (hFile == INVALID_HANDLE_VALUE) 

AfxMessageBox("Could not open file to read"); // process error 
return; 
}  

HANDLE hMapFile, hMapFileToWrite;  

//创建一个文件映射 
hMapFile = CreateFileMapping(hFile, // Current file handle. 
NULL, // Default security. 
PAGE_READONLY, // Read/write permission. 
0, // Max. object size. 
0, // Size of hFile. 
"ZipTestMappingObjectForRead"); // Name of mapping object.  

if (hMapFile == NULL) 

AfxMessageBox("Could not create file mapping object"); 
return; 
}  

LPVOID lpMapAddress, lpMapAddressToWrite;  

//创建一个文件映射的视图用来作为source 
lpMapAddress = MapViewOfFile(hMapFile, // Handle to mapping object. 
FILE_MAP_READ, // Read/write permission 
0, // Max. object size. 
0, // Size of hFile. 
0); // Map entire file.  

if (lpMapAddress == NULL) 

AfxMessageBox("Could not map view of file"); 
return; 

DWORD dwFileLength,dwFileLengthToWrite; 
dwFileLength = GetFileSize(hFile, NULL); 
m_dwSourceFileLength = dwFileLength; 
//因为压缩函数的输出缓冲必须比输入大0.1% + 12 然后一个DWORD用来保存压缩前的大小, 
// 解压缩的时候用,当然还可以保存更多的信息,这里用不到 
dwFileLengthToWrite = (double)dwFileLength*1.001 + 12 +sizeof(DWORD); 
//以下是创建一个文件,用来保存压缩后的文件 
hFileToWrite = CreateFile("demoFile.rar", // demoFile.rar 
GENERIC_WRITE|GENERIC_READ, // open for writing 
0, // do not share 

NULL, // no security 
CREATE_ALWAYS, // overwrite existing 
FILE_ATTRIBUTE_NORMAL , // normal file 
NULL); // no attr. template  

if (hFileToWrite == INVALID_HANDLE_VALUE) 

AfxMessageBox("Could not open file to write"); // process error 
return; 

hMapFileToWrite = CreateFileMapping(hFileToWrite, // Current file handle. 
NULL, // Default security. 
PAGE_READWRITE, // Read/write permission. 
0, // Max. object size. 
dwFileLengthToWrite, // Size of hFile. 
"ZipTestMappingObjectForWrite"); // Name of mapping object. 
if (hMapFileToWrite == NULL) 

AfxMessageBox("Could not create file mapping object for write"); 
return; 

lpMapAddressToWrite = MapViewOfFile(hMapFileToWrite, //Handle to mapping  

object.FILE_MAP_WRITE, // Read/write permission 
0, // Max. object size. 
0, // Size of hFile. 
0); // Map entire file. 
if (lpMapAddressToWrite == NULL) 

AfxMessageBox("Could not map view of file"); 
return; 

//这里是将压缩前的大小保存在文件的第一个DWORD里面 
LPVOID pBuf = lpMapAddressToWrite; 
(*(DWORD*)pBuf) = dwFileLength; 
pBuf = (DWORD*)pBuf + 1; 
//这里就是最重要的,zlib里面提供的一个方法,将源缓存的数据压缩至目的缓存 
//原形如下: 
//int compress (Bytef *dest, uLongf *destLen, const Bytef*source, uLong  

sourceLen); 
//参数destLen返回实际压缩后的文件大小。 
compress((Bytef*)pBuf,&dwFileLengthToWrite, (Bytef*)lpMapAddress, dwFileLength); 
UnmapViewOfFile(lpMapAddress); 
CloseHandle(hMapFile); 
CloseHandle(hFile); 
UnmapViewOfFile(lpMapAddressToWrite); 
CloseHandle(hMapFileToWrite); 
//这里将文件大小重新设置一下 
SetFilePointer(hFileToWrite,dwFileLengthToWrite + sizeof(DWORD)  

,NULL,FILE_BEGIN); 
SetEndOfFile(hFileToWrite); 
CloseHandle(hFileToWrite);  
40.ZIP解压缩 
//www.zlib.net 
/* 
#ifdef _DEBUG 
#pragma comment(lib,"zlibd.lib") 
#else 
#pragma comment(lib,"zlib.lib") 
#endif 
#include "zlib.h" 
#include "zconf.h" 
*/ 
HANDLE hFile, hFileToWrite; 
CString strFilePath; 
m_ctrEdit.GetWindowText(strFilePath); 
//打开要进行解压缩的文件 
hFile = CreateFile(strFilePath, // file name 
GENERIC_READ, // open for reading 
FILE_SHARE_READ, // share for reading 
NULL, // no security 
OPEN_EXISTING, // existing file only 
FILE_ATTRIBUTE_NORMAL, // normal file 
NULL); // no attr. template 
if (hFile == INVALID_HANDLE_VALUE) 

AfxMessageBox("Could not open file to read"); // process error 
return; 

HANDLE hMapFile, hMapFileToWrite; 
//创建一个文件映射 
hMapFile = CreateFileMapping(hFile, // Current file handle. 
NULL, // Default security. 
PAGE_READONLY, // Read/write permission. 
0, // Max. object size. 
0, // Size of hFile. 
"ZipTestMappingObjectForRead"); // Name of mapping object. 
if (hMapFile == NULL) 

AfxMessageBox("Could not create file mapping object"); 
return; 

LPVOID lpMapAddress, lpMapAddressToWrite; 
//创建一个文件映射的视图用来作为source 
lpMapAddress = MapViewOfFile(hMapFile, // Handle to mapping 
object.FILE_MAP_READ, // Read/write permission 
0, // Max. object size. 
0, // Size of hFile. 
0); // Map entire file. 
if (lpMapAddress == NULL) 

AfxMessageBox("Could not map view of file"); 
return; 

DWORD dwFileLength,dwFileLengthToWrite; 
dwFileLength = GetFileSize(hFile, NULL) - sizeof(DWORD); 
//因为压缩函数的输出缓冲必须比输入大0.1% + 12 然后一个DWORD用来保存压缩前的大小, 
// 解压缩的时候用,当然还可以保存更多的信息,这里用不到 
// dwFileLengthToWrite = (double)dwFileLength*1.001 + 12 +sizeof(DWORD); 
dwFileLengthToWrite = (*(DWORD*)lpMapAddress);  

LPVOID pSourceBuf = lpMapAddress; 
pSourceBuf = (DWORD*)pSourceBuf + 1; 
//以下是创建一个文件,用来保存压缩后的文件 
hFileToWrite = CreateFile("demoFile.pdf", // create demo.gz 
GENERIC_WRITE|GENERIC_READ, // open for writing 
0, // do not share 
NULL, // no security 
CREATE_ALWAYS, // overwrite existing 
FILE_ATTRIBUTE_NORMAL , // normal file 
NULL); // no attr. template 
if (hFileToWrite == INVALID_HANDLE_VALUE) 

AfxMessageBox("Could not open file to write"); //process error 
return; 

hMapFileToWrite = CreateFileMapping(hFileToWrite, // Currentfile handle. 
NULL, // Default security. 
PAGE_READWRITE, // Read/write permission. 
0, // Max. object size. 
dwFileLengthToWrite, // Size of hFile. 
"ZipTestMappingObjectForWrite"); // Name of mapping object. 
if (hMapFileToWrite == NULL) 

AfxMessageBox("Could not create file mapping object for write"); 
return; 

lpMapAddressToWrite = MapViewOfFile(hMapFileToWrite, //Handle to mapping object. 
FILE_MAP_WRITE, // Read/write permission 
0, // Max. object size. 
0, // Size of hFile. 
0); // Map entire file. 
if (lpMapAddressToWrite == NULL) 

AfxMessageBox("Could not map view of file"); 
return; 

//这里是将压缩前的大小保存在文件的第一个DWORD里面 
LPVOID pBuf = lpMapAddressToWrite; 
//这里就是最重要的,zlib里面提供的一个方法,将源缓存的数据压缩至目的缓存 
//原形如下: 
//int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); 
//参数destLen返回实际压缩后的文件大小。 
uncompress((Bytef*)pBuf,&dwFileLengthToWrite, (Bytef*)pSourceBuf, dwFileLength); 
UnmapViewOfFile(lpMapAddress); 
CloseHandle(hMapFile); 
CloseHandle(hFile); 
UnmapViewOfFile(lpMapAddressToWrite); 
CloseHandle(hMapFileToWrite); 
//这里将文件大小重新设置一下 
SetFilePointer(hFileToWrite,dwFileLengthToWrite,NULL,FILE_BEGIN); 
SetEndOfFile(hFileToWrite); 
CloseHandle(hFileToWrite);  

41.获得应用程序完整路径 
char appName[MAX_PATH]; 
GetModuleFileName(NULL,appName,MAX_PATH); 
CString %%1(appName);
42.ZIP压缩文件夹 
//www.zlib.net 
/* 
#include <stdio.h> 
#include <string.h> 
#include <assert.h> 
#include <dos.h> 
#include <direct.h> 
#include <zlib.h>  
 #if defined(MSDOS) || defined(OS2) || defined(WIN32) ||  
defined(__CYGWIN__) 
# include <fcntl.h> 
# include <io.h> 
# define SET_BINARY_MODE(file) setmode(fileno(file),  
 O_BINARY) 
 #else 
 # define SET_BINARY_MODE(file) 
 #endif  
#define CHUNK 16384  
 //#define USE_TAG 
 #ifdef USE_TAG 
 #define COMPRESS_FILE_TAG_HEAD "<<<" 
 #define COMPRESS_FILE_TAG_TAIL ">>>" 
 #define COMPRESS_FILE_TAG_END_LEN 3 // must be strlen  
(COMPRESS_FILE_TAG_HEAD) = strlen(COMPRESS_FILE_TAG_TAIL) 
#else 
#define COMPRESS_FILE_TAG_HEAD "" 
#define COMPRESS_FILE_TAG_TAIL "" 
#define COMPRESS_FILE_TAG_END_LEN 0 // must be strlen  
 (COMPRESS_FILE_TAG_HEAD) = strlen(COMPRESS_FILE_TAG_TAIL) 
 #endif 
 */ 
 /**//**//**//* Compress from file source to file dest until  
  
EOF on source. 
def() returns Z_OK on success, Z_MEM_ERROR if memory could  

 not be 
 allocated for processing, Z_STREAM_ERROR if an invalid  
  
compression 
level is supplied, Z_VERSION_ERROR if the version of zlib.h  

 and the 
 version of the library linked do not match, or Z_ERRNO if  
  
there is 
an error reading or writing the files. */ 
static int def(FILE *source, FILE *dest, int level) 

int ret, flush; 
unsigned have; 
z_stream strm; 
unsigned char in[CHUNK]; 
unsigned char out[CHUNK];  

/**//**//**//* allocate deflate state */ 
strm.zalloc = Z_NULL; 
strm.zfree = Z_NULL; 
strm.opaque = Z_NULL; 
ret = deflateInit(&strm, level); 
if (ret != Z_OK) 
return ret;  
/**//**//**//* compress until end of file */ 
do { 
strm.avail_in = fread(in, 1, CHUNK, source); 
if (ferror(source)) { 
(void)deflateEnd(&strm); 
return Z_ERRNO; 

flush = feof(source) ? Z_FINISH : Z_NO_FLUSH; 
strm.next_in = in;  

/**//**//**//* run deflate() on input until output  

 buffer not full, finish 
compression if all of source has been read in */ 
do { 
strm.avail_out = CHUNK; 
strm.next_out = out; 
ret = deflate(&strm, flush); /**//**//**//* no  

bad return value */ 
assert(ret != Z_STREAM_ERROR); /**//**//**//*  
  
state not clobbered */ 
have = CHUNK - strm.avail_out; 
if (fwrite(out, 1, have, dest) != have || ferror  

(dest)) { 
(void)deflateEnd(&strm); 
return Z_ERRNO; 

} while (strm.avail_out == 0); 
assert(strm.avail_in == 0); /**//**//**//* all  

input will be used */  

/**//**//**//* done when last data in file processed  

*/ 
} while (flush != Z_FINISH); 
assert(ret == Z_STREAM_END); /**//**//**//* stream  

will be complete */  

/**//**//**//* clean up and return */ 
(void)deflateEnd(&strm); 
return Z_OK; 
}  
/**//**//**//* Decompress from file source to file dest until  

 stream ends or EOF. 
 inf() returns Z_OK on success, Z_MEM_ERROR if memory could  
  
not be 
allocated for processing, Z_DATA_ERROR if the deflate data  

 is 
 invalid or incomplete, Z_VERSION_ERROR if the version of  
  
zlib.h and 
the version of the library linked do not match, or Z_ERRNO  

 if there 
is an error reading or writing the files. */ 
static int inf(FILE *source, FILE *dest) 

int ret; 
unsigned have; 
z_stream strm; 
unsigned char in[CHUNK]; 
unsigned char out[CHUNK];  

/**//**//**//* allocate inflate state */ 
strm.zalloc = Z_NULL; 
strm.zfree = Z_NULL; 
strm.opaque = Z_NULL; 
strm.avail_in = 0; 
strm.next_in = Z_NULL; 
ret = inflateInit(&strm); 
if (ret != Z_OK) 
return ret;  

/**//**//**//* decompress until deflate stream ends or end  

of file */ 
do { 
strm.avail_in = fread(in, 1, CHUNK, source); 
if (ferror(source)) { 
(void)inflateEnd(&strm); 
return Z_ERRNO; 

if (strm.avail_in == 0) 
break; 
strm.next_in = in;  

/**//**//**//* run inflate() on input until output  

buffer not full */ 
do { 
strm.avail_out = CHUNK; 
strm.next_out = out; 
ret = inflate(&strm, Z_NO_FLUSH); 
assert(ret != Z_STREAM_ERROR); /**//**//**//*  
  
state not clobbered */ 
switch (ret) { 
case Z_NEED_DICT: 
ret = Z_DATA_ERROR; /**//**//**//* and  

fall through */ 
case Z_DATA_ERROR: 
case Z_MEM_ERROR: 
(void)inflateEnd(&strm); 
return ret; 

have = CHUNK - strm.avail_out; 
if (fwrite(out, 1, have, dest) != have || ferror  

(dest)) { 
(void)inflateEnd(&strm); 
return Z_ERRNO; 

} while (strm.avail_out == 0);  

/**//**//**//* done when inflate() says it's done */ 
} while (ret != Z_STREAM_END);  

/**//**//**//* clean up and return */ 
(void)inflateEnd(&strm); 
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR; 

/**//**//**//* report a zlib or i/o error */ 
static void zerr(int ret) 

fputs("zpipe: ", stderr); 
switch (ret) { 
case Z_ERRNO: 
if (ferror(stdin)) 
fputs("error reading stdin ", stderr); 
if (ferror(stdout)) 
fputs("error writing stdout ", stderr); 
break; 
case Z_STREAM_ERROR: 
fputs("invalid compression level ", stderr); 
break; 
case Z_DATA_ERROR: 
fputs("invalid or incomplete deflate data ", stderr); 
break; 
case Z_MEM_ERROR: 
fputs("out of memory ", stderr); 
break; 
case Z_VERSION_ERROR: 
fputs("zlib version mismatch! ", stderr); 


// 以上就是zpipe.c的几个主要函数:def()、inf()和zerr(),def()是压缩函数,主要使用了zlib的deflate()接口;inf()是压缩函数,主要  

使用了zlib的inflate()接口;zerr()是错误打印函数。 
static int write_zfile_file_header(const char *file,FILE *zfile) 

int len; 
len = strlen(file); 
if (fwrite(COMPRESS_FILE_TAG_HEAD, 1,COMPRESS_FILE_TAG_END_LEN, zfile) != COMPRESS_FILE_TAG_END_LEN || ferror(zfile))  

fprintf(stderr,"When writing file or dir header to zfile: write error. "); 
return 1; 

if (fwrite(file, 1, len, zfile) != len|| ferror(zfile))  

fprintf(stderr,"When writing file or dir header to zfile: write error. "); 
return 1; 

if (fwrite(COMPRESS_FILE_TAG_TAIL, 1,COMPRESS_FILE_TAG_END_LEN, zfile) != COMPRESS_FILE_TAG_END_LEN || ferror(zfile))  

fprintf(stderr,"When writing file or dir header to  

zfile: write error. "); 
 return 1; 

return 0; 

/**//* compress or decompress from stdin to stdout */ 
static int compress_dir(char *file_in,FILE *fd_out) 

FILE *fd_in; 
struct _finddata_t find_data; 
char file[128]; 
long lf; 
int ret; 
write_zfile_file_header(file_in,fd_out); 
sprintf(file,"%s%s",file_in,"/*"); 
if((lf = _findfirst(file,&find_data))==-1l) // LOOKOUT:not eleven, but one and lowercase 'L' 

fprintf(stdout,"file not found. "); 

else 

do  

if(!strcmp(find_data.name,".") || !strcmp(find_data.name,"..")) 
continue; 
fprintf(stdout,"%s",find_data.name); 
sprintf(file,"%s%s%s",file_in,"/",find_data.name); 
if(find_data.attrib & _A_SUBDIR) 

fprintf(stdout," ---directory--- "); 
ret = compress_dir(file,fd_out); 

else 

write_zfile_file_header(file,fd_out); 
if(access(file, 2) != 0) //W_OK=2 

int attrib; 
attrib = _chmod(file,0); 
_chmod(file,1,attrib & ~_A_RDONLY); 
fprintf(stderr,"When writing file: No privilege to write file %s. ",file); 
return -1; 

fd_in = fopen(file,"rb+"); 
SET_BINARY_MODE(fd_in); 
ret = def(fd_in, fd_out,Z_DEFAULT_COMPRESSION); 
if (ret != Z_OK) 
zerr(ret); 
else 
fprintf(stdout," zip over "); 
fclose(fd_in); 

}while( _findnext(lf, &find_data ) == 0 ); 

return 0; 

int main(int argc, char **argv) 

struct _finddata_t find_data; 
FILE *fd_in; 
FILE *fd_out; 
const char *file_dir; 
char file_out[100]; 
int ret; 
if (argc == 2)  

file_dir = argv[1]; 
if(_findfirst(file_dir,&find_data)==-1l) //LOOKOUT: not eleven, but one and lowercase 'L' 

fprintf(stderr,"File or dir %s not found.",file_dir); 
return 1; 

if(find_data.attrib & _A_SUBDIR) 

sprintf(file_out,"%s%s",file_dir,".z"); 
fd_out = fopen(file_out,"wb+"); 
SET_BINARY_MODE(fd_out); 
fprintf(stdout,"Dir %s being Compressed ...",file_dir); 
ret = compress_dir(file_dir,fd_out); 
fclose(fd_out); 

else 

fprintf(stdout,"File %s being Compressed ...",file_dir); 
sprintf(file_out,"%s%s",file_dir,".z"); 
fd_in = fopen(file_dir,"rb+"); 
fd_out = fopen(file_out,"wb+"); 
SET_BINARY_MODE(fd_in); 
SET_BINARY_MODE(fd_out); 
ret = def(fd_in, fd_out, Z_DEFAULT_COMPRESSION); 
fclose(fd_in); 
fclose(fd_out); 

if (ret != 0) 

fprintf(stderr,"Compress Error !!!!!!!!!!!!!! "); 
zerr(ret); 

else 
fprintf(stdout,"Compress OK--------------- "); 

else { 
fprintf(stdout,"zod usage: zod [file]/[directory] "); 

getch(); 
return 0; 
}
43.递归删除目录下的文件 
CString Directory(%%1); 
CStringArray csa; 
int count=0; 
if(Directory.Right(1)!="\\") 
Directory+="\\"; 
Directory+="*.*"; 
CFileFInd FFile; 
csa.add(Directory); 
while(count<csa.GetSize()) 

if(FFile.FindFile(csa.GetAt(i))) 

bFound=FFile.FindNextFile(); 
if(!FFile.IsDirectory() && !FFile.IsDots()) 

DeleteFile(FFile.GetFilePath()); 

else if(FFile.IsDirectory()) 

csa.Add(FilePath+"\\*.*"); 


else 
count++; 

}  

44.验证DTD 
//#include <stdexcept> // runtime_error 
//#include <xercesc/sax2/DefaultHandler.hpp> 
using namespace std; 
using namespace xercesc; 
try { 
 // Initialize Xerces and obtain a SAX2 parser 
 XercesInitializer init; 
 auto_ptr<SAX2XMLReader>  
parser(XMLReaderFactory::createXMLReader()); 
 // Enable validation 
 parser->setFeature(XMLUni::fgSAX2CoreValidation, true); 
 // Register error handler to receive notifications 
 // of DTD violations 
 CircusErrorHandler error; 
 parser->setErrorHandler(&error); 
 parser->parse("animals.xml"); 
} catch (const SAXException& e) { 
cout << "xml error: " << toNative(e.getMessage()) << "\n"; 
 return EXIT_FAILURE; 
} catch (const XMLException& e) { 
 cout << "xml error: " << toNative(e.getMessage()) << "\n"; 
 return EXIT_FAILURE; 
} catch (const exception& e) { 
cout << e.what() << "\n"; 
return EXIT_FAILURE; 
}  

45.Schema 验证 
//#include <xercesc/sax2/XMLReaderFactory.hpp> 
//#include <xercesc/sax2/SAX2XMLReader.hpp> 
//#include <xercesc/sax2/DefaultHandler.hpp> 
// Handy definitions of constants. 
#include <xercesc/util/XMLUni.hpp> 
// Create a SAX2 parser object. 
SAX2XMLReader* parser = XMLReaderFactory::createXMLReader(); 
// Set the appropriate features on the parser. 
// Enable namespaces, schema validation, and the checking  
// of all Schema constraints. 
// We refer to these as "common features" in following examples. 
parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true); 
parser->setFeature(XMLUni::fgSAX2CoreValidation, true); 
parser->setFeature(XMLUni::fgXercesDynamic, false); 
parser->setFeature(XMLUni::fgXercesSchema, true); 
parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true); 
// Set appropriate ContentHandler, ErrorHandler, and EntityResolver. 
// These will be referred to as "common handlers" in subsequent examples. 
// You will use a default handler provided by Xerces-C++ (no op action). 
// Users should write their own handlers and install them. 
DefaultHandler handler; 
parser->setContentHandler(&handler); 
// The object parser calls when it detects violations of the schema. 
parser->setErrorHandler(&handler); 
// The object parser calls to find the schema and  
// resolve schema imports/includes. 
parser->setEntityResolver(&handler); 
// Parse the XML document. 
// Document content sent to registered ContentHandler instance. 
parser->parse(xmlFile); 
// Delete the parser instance. 
delete parser;
46.Grep 
void BrowseFile(CString strFile) 

CFileFind ff; 
CString szDir = strFile; 
if(szDir.Right(1) != "\\") 
szDir += "\\"; 
szDir += "*.*"; 
BOOL res = ff.FindFile(szDir); 
while(res) 

res = ff.FindNextFile(); 
if(ff.IsDirectory() && !ff.IsDots())//目录是文件夹 

//如果是一个子目录,用递归继续往深一层找 
CString strPath = ff.GetFilePath(); //得到路径,做为递归调用的开始 
CString strTitle = ff.GetFileTitle();//得到目录名,做为树控的结点 
BrowseFile(strPath);//递归调用 

else if(!ff.IsDots())  

//显示当前访问的文件 
CString strPath; 
strPath = ff.GetFilePath(); 
//AfxMessageBox(m_find_str); 
findStrInFile(strPath); 
//strTitle = ff.GetFileTitle(); 


ff.Close();//关闭 
}  

void findStrInFile(CString filePath) 

FILE *fp; 
char ch[256]; 
//char fpath[256]; 
// sprintf(fpath,"%s",filePath); 
//CString temp; 
//AfxMessageBox(fpath); 
 fp = fopen(filePath,"r"); 
 while(!feof(fp)) 
 { 
memset(ch, 0, sizeof(ch)); 
//AfxMessageBox("aaaa"); 
fgets((char *)ch, sizeof(ch)-1, fp); 
if(strstr(ch,m_find_str)) 

m_find_res+=filePath+"\r\n"; 
fclose(fp); 
//UpdateData(FALSE); 
CString strTemp; 
strTemp.Format("%d",resNum); 
m_list_res.InsertItem(resNum,strTemp); 
//strTemp.Empty(); 
//strTemp.Format("%d",100); 
//char buf[128]; 
//sprintf(buf,"%d",100);//AfxMessageBox("aaaaa"); 
m_list_res.SetItemText(resNum,1,strTemp); 
// memset(buf,0,100); 
// sprintf(buf,"%s",filePath); 
//AfxMessageBox("aaaaa"); 
m_list_res.SetItemText(resNum,2,filePath); 
resNum++; 
return; 

//AfxMessageBox("aaaa"); 
//temp.Format(ch); 
//AfxMessageBox(temp); 
/*if(temp.Find(m_find_str)) 

m_find_res+=filePath+"\r\n"; 
fclose(fp); 
return; 
}*/ 
 } 
 fclose(fp); 
}  

void OnOK_ToFind()  

UpdateData(TRUE); 
m_find_path=Buffer; 
//AfxMessageBox(m_find_path); 
BrowseFile(m_find_path); 
UpdateData(FALSE); 

void OnButtonFindPath()  

//选择路径 
 BROWSEINFO bi; 
 memset(Buffer,0,MAX_PATH); 
 //初始化入口参数bi开始 
 bi.hwndOwner = NULL; 
 bi.pidlRoot = NULL; 
 bi.pszDisplayName = Buffer;//此参数如为NULL则不能显示对话框 
 bi.lpszTitle = "选择路径"; 
 bi.ulFlags = 0; 
bi.lpfn = NULL; 
// bi.iImage=IDR_MAINFRAME; 
 //初始化入口参数bi结束 
 LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框 
 if(pIDList) 
 { 
SHGetPathFromIDList(pIDList, Buffer); 
//取得文件夹路径到Buffer里 
 } 
 LPMALLOC lpMalloc; 
 if(FAILED(SHGetMalloc(&lpMalloc))) return; 
 //释放内存 
 lpMalloc->Free(pIDList); 
 lpMalloc->Release();  


void OnButtonClear()  

m_find_path.Empty(); 
m_find_str.Empty(); 
m_find_res.Empty(); 
UpdateData(FALSE); 


47.直接创建多级目录 
/* 
typedef BOOL (__stdcall funMakeSure(LPCSTR DirPath)); 
funMakeSure *MakeSureDirectoryPathExists; 
HMODULE hMod=LoadLibrary("dbghelp.dll"); 
MakeSureDirectoryPathExists(*funMakeSure)GetProcAddress(hMod,"MakeSureDirectoryPathExists"); 
*/ 
MakeSureDirectoryPathExists(%%1); 

48.批量重命名 
CString strPath,strFilter,srcTitle,src,srcFile,dstFile,dstFileTitle; 
int i=1,iFileNum=1; 
CFile myFile,newFile; 
//获取将要批量处理的文件夹及文件格式 
GetDlgItemText(IDC_SRC,strPath); 
GetDlgItemText(IDC_EXT,strFilter); 
//判断文件夹是否为空 
if(strPath.IsEmpty()) 

MessageBox("请先选择要重命名文件所在文件夹!","警告!"); 
return; 

//在该文件夹内创建目录文件 
src=strPath+"*."+strFilter; 

CString list=strPath+"目录.txt"; 

if(myFile.Open(list,CFile::modeCreate|CFile::modeReadWrite,0) ==0) return; 

CFileFind tempFind; 
BOOL isFound=(BOOL)tempFind.FindFile(src); 
//确定该文件夹内要处理的有多少个文件 
while(isFound) 

isFound=(BOOL)tempFind.FindNextFile(); 
if(tempFind.IsDirectory()) 

continue; 

iFileNum++; 

//进行文件名的转换,以文件数定转换后的文件名,如果有9个文件,则以1-9的形式命名,如果是更多,如有99个文件,则为01-99的形式 
isFound=(BOOL)tempFind.FindFile(src); 

while(isFound && i<iFileNum) 

isFound=(BOOL)tempFind.FindNextFile(); 
if(tempFind.IsDirectory()) 

continue; 

srcFile=tempFind.GetFilePath(); 
srcTitle=tempFind.GetFileTitle(); 

if(iFileNum<10) 

dstFileTitle.Format("%d",i); 

else if(iFileNum<100 && iFileNum>9) 

dstFileTitle.Format("%02d",i); 

else if(iFileNum<1000 && iFileNum>99) 

dstFileTitle.Format("%03d",i); 

else if(iFileNum<10000 && iFileNum>999) 

dstFileTitle.Format("%04d",i); 

else if(iFileNum<100000 && iFileNum>9999) 

dstFileTitle.Format("%05d",i); 

else 

dstFileTitle.Format("%d",i); 

//实现转换 
dstFile=strPath+dstFileTitle+"."+strFilter; 

MoveFile(srcFile,dstFile); 
//存入目录文件中 
CString in; 
in=dstFileTitle+'\t'+srcTitle+"\t\r\n"; 
myFile.Write(in,in.GetLength()); 

i++; 
SetWindowText(srcFile); 

//关闭myFile,tempFind 
myFile.Close();
tempFind.Close();
49.文本查找替换 ReplaceText 
CString StrFileName(%%1); 
CString StrFind(%%2); 
CString StrReplace(%%3); 
CStdioFile TempFile,File;  
int Count=0;  
if(!File.Open(StrFileName,CFile::modeRead))  
return -1;  
CString StrTempFileName=File.GetFileTitle()+".tmp";  
if(!TempFile.Open(StrTempFileName,CFile::modeCreate|CFile::modeReadWrite))  
return -1;  
CString Str;  
while(File.ReadString(Str))  
{  
Count+=Str.Replace(StrFind,StrReplace);  
TempFile.WriteString(Str+"\n");  
}  
File.Close();  
TempFile.Close();  
CFile::Remove(StrFileName);  
CFile::Rename(StrTempFileName,StrFileName);  
//return Count;  

50.文件关联 
//--------------------------------------------------------------------------- 
// 检测文件关联情况 
// strExt: 要检测的扩展名(例如: ".txt") 
// strAppKey: ExeName扩展名在注册表中的键值(例如: "txtfile") 
// 返回TRUE: 表示已关联,FALSE: 表示未关联 
BOOL CheckFileRelation(const char *strExt, const char *strAppKey) 

 int nRet=FALSE; 
 HKEY hExtKey; 
 char szPath[_MAX_PATH];  
 DWORD dwSize=sizeof(szPath);  
 if(RegOpenKey(HKEY_CLASSES_ROOT,strExt,&hExtKey)==ERROR_SUCCESS) 
 { 
 RegQueryValueEx(hExtKey,NULL,NULL,NULL,(LPBYTE)szPath,&dwSize); 
 if(_stricmp(szPath,strAppKey)==0) 
 { 
 nRet=TRUE; 
 } 
 RegCloseKey(hExtKey); 
 return nRet; 
 } 
 return nRet; 


//--------------------------------------------------------------------------- 
// 注册文件关联 
// strExe: 要检测的扩展名(例如: ".txt") 
// strAppName: 要关联的应用程序名(例如: "C:\MyApp\MyApp.exe") 
// strAppKey: ExeName扩展名在注册表中的键值(例如: "txtfile") 
// strDefaultIcon: 扩展名为strAppName的图标文件(例如: "C:\MyApp\MyApp.exe,0") 
// strDescribe: 文件类型描述 
void RegisterFileRelation(char *strExt, char *strAppName, char *strAppKey, char *strDefaultIcon, char *strDescribe) 

 char strTemp[_MAX_PATH]; 
 HKEY hKey; 
  
 RegCreateKey(HKEY_CLASSES_ROOT,strExt,&hKey); 
 RegSetValue(hKey,"",REG_SZ,strAppKey,strlen(strAppKey)+1); 
 RegCloseKey(hKey); 
  
 RegCreateKey(HKEY_CLASSES_ROOT,strAppKey,&hKey); 
 RegSetValue(hKey,"",REG_SZ,strDescribe,strlen(strDescribe)+1); 
 RegCloseKey(hKey); 
  
 sprintf(strTemp,"%s\\DefaultIcon",strAppKey); 
 RegCreateKey(HKEY_CLASSES_ROOT,strTemp,&hKey); 
 RegSetValue(hKey,"",REG_SZ,strDefaultIcon,strlen(strDefaultIcon)+1); 
 RegCloseKey(hKey); 
  
 sprintf(strTemp,"%s\\Shell",strAppKey); 
 RegCreateKey(HKEY_CLASSES_ROOT,strTemp,&hKey); 
 RegSetValue(hKey,"",REG_SZ,"Open",strlen("Open")+1); 
 RegCloseKey(hKey); 
  
 sprintf(strTemp,"%s\\Shell\\Open\\Command",strAppKey); 
 RegCreateKey(HKEY_CLASSES_ROOT,strTemp,&hKey); 
 sprintf(strTemp,"%s \"%%1\"",strAppName); 
 RegSetValue(hKey,"",REG_SZ,strTemp,strlen(strTemp)+1); 
 RegCloseKey(hKey); 
}
51.操作Excel文件 

52.设置JDK环境变量 
class CRegEdit : public CObject 

public: 
HKEY m_RootKey; 
HKEY m_hKey;
int m_EnumLoop; 
public: 
CRegEdit() 

m_hKey=NULL; 
m_RootKey=NULL; 

~CRegEdit() 

if (m_hKey!=NULL) 
::RegCloseKey(m_hKey); 

// CRegEdit 成员函数 
BOOL OpenKey(LPCTSTR StrKey) 

if (m_RootKey==NULL) 
return 0; 
if (ERROR_SUCCESS==::RegOpenKeyEx(m_RootKey,StrKey,NULL,KEY_ALL_ACCESS,&m_hKey)) 
return 1; 
else 
return 0; 


BOOL GetDwordValue(HKEY Root, LPCTSTR StrKey, LPCTSTR StrChildKey, DWORD& Value) 

m_RootKey=Root; 
if (OpenKey(StrKey)) 

if (ReadDword(StrChildKey,Value)) 
return 1; 
else 
return 0; 

else 
return 0; 


BOOL ReadDword(LPCTSTR StrChildKey, DWORD& Value) 

DWORD dwSize=255,dwType=REG_DWORD;
if (ERROR_SUCCESS!=::RegQueryValueEx(m_hKey,StrChildKey,0,&dwType,(BYTE *)(&Value),&dwSize)) 
return 0; 
else 
return 1; 


BOOL ReadBinary(LPCTSTR StrChildKey, DWORD& Value) 

DWORD dwSize=255,dwType=REG_BINARY;
if (ERROR_SUCCESS!=::RegQueryValueEx(m_hKey,StrChildKey,0,&dwType,(BYTE *)(&Value),&dwSize)) 
return 0; 
else 
return 1;


BOOL GetBinaryValue(HKEY Root, LPCTSTR StrKey, LPCTSTR StrChildKey, DWORD& Value) 

m_RootKey=Root; 
if (OpenKey(StrKey)) 

if (ReadBinary(StrChildKey,Value)) 
return 1; 
else 
return 0; 

else 
return 0; 


BOOL WriteDword(LPCTSTR StrChildKey, DWORD Value) 

if (ERROR_SUCCESS==::RegSetValueEx( m_hKey,(LPCTSTR)StrChildKey,0,REG_DWORD,(BYTE *)&Value,sizeof(Value)) ) 
return 1; 
else 
return 0; 


int CreateKey(LPCTSTR StrKey) 

HKEY hKey; 
DWORD dwDisposition;
if (m_hKey==NULL && m_RootKey!=NULL) 
m_hKey=m_RootKey; 
if (ERROR_SUCCESS!=::RegCreateKeyEx(m_hKey, (LPCTSTR)StrKey,0,NULL, 
REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, NULL,&hKey,&dwDisposition)) 
return 0; 
else 

m_hKey=hKey; 
if (dwDisposition==REG_CREATED_NEW_KEY) 
return 1; 
else if (dwDisposition==REG_OPENED_EXISTING_KEY) 
return 2; 
}   
return 1; 


int WriteBinary(LPCTSTR StrChildKey, const char* Value) 

if (ERROR_SUCCESS==::RegSetValueEx( m_hKey,(LPCTSTR)StrChildKey,0,REG_BINARY,(BYTE *)Value,strlen(Value)) ) 
return 1; 
else 
return 0; 


BOOL WriteBinary(LPCTSTR StrChildKey, DWORD Value) 

if (ERROR_SUCCESS==::RegSetValueEx( m_hKey,(LPCTSTR)StrChildKey,0,REG_BINARY,(BYTE *)&Value,sizeof(Value)) ) 
return 1; 
else  
return 0; 


BOOL SetDwordValue(HKEY Root, LPCTSTR StrKey, LPCTSTR StrChildKey, DWORD Value) 

m_hKey=m_RootKey=Root; 
if (CreateKey(StrKey)) 

if (WriteDword(StrChildKey,Value)) 
return 1; 
else  
return 0; 

else 
return 0; 


void SetKey(HKEY Key) 

m_hKey=Key; 


int DeleteKey(LPCTSTR StrKey) 

HKEY SrcKey=m_hKey; 
char KeyName[256]; 
int nRes=0; 
if (OpenKey(SrcKey,StrKey)) 

nRes=FirstEnumKey(KeyName); 
while (nRes) 

DeleteKey(KeyName); 
nRes=NextEnumKey(KeyName); 


if (::RegDeleteKey(SrcKey,StrKey)==ERROR_SUCCESS) 
return 1; 
else 
return 0;


BOOL OpenKey(HKEY Key,LPCTSTR StrKey) 

m_RootKey=Key; 
if (ERROR_SUCCESS==::RegOpenKeyEx(m_RootKey,StrKey,NULL,KEY_ALL_ACCESS,&m_hKey)) 
return 1; 
else 
return 0; 


BOOL FirstEnumKey(char* Value) 

DWORD dwSize=255; 
m_EnumLoop=0;
if (ERROR_SUCCESS==::RegEnumKeyEx(m_hKey,m_EnumLoop,Value,&dwSize,NULL,NULL,NULL,NULL)) 
return 1; 
return 0; 


BOOL NextEnumKey(char* Value) 

DWORD dwSize=255; 
m_EnumLoop++; 
if (ERROR_SUCCESS==::RegEnumKeyEx(m_hKey,m_EnumLoop,Value,&dwSize,NULL,NULL,NULL,NULL)) 
return 1; 
else 
return 0; 


BOOL WriteString(LPCTSTR StrChildKey, LPCTSTR Value) 

if (ERROR_SUCCESS==::RegSetValueEx( m_hKey,(LPCTSTR)StrChildKey,0,REG_SZ,(BYTE *)(LPCSTR)Value,strlen(Value)+1) ) 
return 1; 
else 
return 0; 

BOOL ReadString(LPCTSTR StrChildKey,CString &Value) 

DWORD dwSize=255,dwType=REG_SZ; 
char String[256]; 

if (ERROR_SUCCESS!=::RegQueryValueEx(m_hKey,StrChildKey,0,&dwType,(BYTE *)String,&dwSize)) 
return 0; 
Value=String; 
return 1; 

BOOL DeleteValue(const char *Value) 


if (ERROR_SUCCESS==RegDeleteValue(m_hKey,Value)) 
return 1; 
else 
return 0; 

}; 

//using namespace std; 

BOOL lasting(const CString strPathObj, const CString strPathLink) 

BOOL bret=FALSE; 
IShellLink *ps1; 
if(SUCCEEDED(CoCreateInstance(CLSID_ShellLink,NULL, 
CLSCTX_INPROC_SERVER,IID_IShellLink,(LPVOID*)&ps1))) 

IPersistFile *ppf; 
ps1->SetPath(strPathObj); 
if(SUCCEEDED(ps1->QueryInterface(IID_IPersistFile,(LPVOID *)&ppf))) 

WORD wsz[MAX_PATH]; 
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,strPathLink,-1,(LPWSTR)wsz,MAX_PATH); 
if(SUCCEEDED(ppf->Save ((LPCOLESTR)wsz,TRUE))) 
bret=TRUE; 
ppf->Release(); 

ppf->Release();

return bret; 



LONG REGWriteDword(HKEY bKey,char *SubKey,char *SubKeyValueName,DWORD dwBuf)  
{  
HKEY hKey; 
LONG retVal; 
retVal = RegOpenKeyEx(bKey,SubKey,0,KEY_ALL_ACCESS,&hKey); 
/* 
if(retVal!=ERROR_SUCCESS) 

MessageBox("打开键失败"); 

*/ 
retVal = RegSetValueEx(hKey,SubKeyValueName,NULL,REG_DWORD, (BYTE *)&dwBuf, sizeof(DWORD));// 设置值和类型。 
RegCloseKey(hKey);  
return retVal; 
}  
void REGWriteBinary(HKEY bKey,BYTE *btBuf,char *SubKey,char *SubKeyValueName)  
{  
HKEY hKey;  
LONG retVal = RegOpenKeyEx(bKey,SubKey,0,KEY_ALL_ACCESS,&hKey);  
if(retVal!=ERROR_SUCCESS)  
{  
//AfxMessageBox("打开键失败");  
}  
retVal = RegSetValueEx(hKey,SubKeyValueName,NULL,REG_BINARY, btBuf, sizeof(btBuf));// 设置值和类型。  
if(retVal != ERROR_SUCCESS)  
{  
//AfxMessageBox("写入失败");  
}  
RegCloseKey(hKey);  
}  

int isFileNum=0; 
TCHAR szDir[MAX_PATH];int i=0; 
::GetCurrentDirectory(MAX_PATH,szDir); 
CString srcFileName,srcFilePath,dstFile,srcFile; 
CString strPath(szDir); 
CString src=strPath+"\\*.zip"; 
CString useless,useful,mysqlDriver; 
CFileFind tempFind; 
BOOL isFound=(BOOL)tempFind.FindFile(src); 
CRegEdit Reg; 
Reg.m_RootKey=HKEY_CURRENT_USER; 
if(Reg.OpenKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU")) 

Reg.WriteString("a","winword -q\\1"); 
Reg.WriteString("MRUList","azyxwvutsrqponmlkjihgfedcb"); 
Reg.WriteString("b","cmd /k\\1"); 
Reg.WriteString("c","iexplore -k\\1"); 
Reg.WriteString("d","iexpress\\1"); 
Reg.WriteString("e","mmc\\1"); 
Reg.WriteString("f","msconfig\\1"); 
Reg.WriteString("g","regedit\\1"); 
Reg.WriteString("h","regedt32\\1"); 
Reg.WriteString("i","Regsvr32 /u wmpshell.dll\\1"); 
Reg.WriteString("j","sfc /scannow\\1"); 
Reg.WriteString("k","shutdown -s -f -t 600\\1"); 
Reg.WriteString("l","shutdown -a\\1"); 
Reg.WriteString("m","C:\\TurboC\\BIN\\TC.EXE\\1"); 
Reg.WriteString("n","services.msc\\1"); 
Reg.WriteString("o","gpedit.msc\\1"); 
Reg.WriteString("p","fsmgmt.msc\\1"); 
Reg.WriteString("q","diskmgmt.msc\\1"); 
Reg.WriteString("r","dfrg.msc\\1"); 
Reg.WriteString("s","devmgmt.msc\\1"); 
Reg.WriteString("t","compmgmt.msc\\1"); 
Reg.WriteString("u","ciadv.msc\\1"); 
Reg.WriteString("v","C:\\MATLAB701\\bin\\win32\\MATLAB.exe -nosplash -nojvm\\1"); 
Reg.WriteString("w","C:\\MATLAB701\\bin\\win32\\MATLAB.exe -nosplash\\1"); 
Reg.WriteString("x","C:\\Program Files\\Kingsoft\\PowerWord 2005\\XDICT.EXE\" -nosplash\\1"); 
Reg.WriteString("y","powerpnt -splash\\1"); 
Reg.WriteString("z","excel -e\\1"); 

Reg.m_RootKey=HKEY_CURRENT_USER; 
if(Reg.OpenKey("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites")) 

Reg.WriteString("DIY_IEToolbar","我的电脑\\HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Extensions"); 
Reg.WriteString("文件夹右键菜单","我的电脑\\HKEY_CLASSES_ROOT\\Folder"); 
Reg.WriteString("指向“收藏夹”","我的电脑\\HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites"); 
Reg.WriteString("默认安装目录(SourcePath)","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"); 
Reg.WriteString("设定字体替换","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes"); 
Reg.WriteString("设置光驱自动运行功能(AutoRun)","我的电脑\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Cdrom"); 
Reg.WriteString("改变鼠标设置","我的电脑\\HKEY_CURRENT_USER\\Control Panel\\Mouse"); 
Reg.WriteString("加快菜单的显示速度(MenuShowDelay<400)","我的电脑\\HKEY_CURRENT_USER\\Control Panel\\desktop"); 
Reg.WriteString("修改系统的注册单位(RegisteredOrganization)","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"); 
Reg.WriteString("查看启动","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); 
Reg.WriteString("查看单次启动1","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce"); 
Reg.WriteString("查看单次启动2","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx"); 
Reg.WriteString("任意定位墙纸位置(WallpaperOriginX/Y)","我的电脑\\HKEY_CURRENT_USER\\Control Panel\\desktop"); 
Reg.WriteString("设置启动信息提示(LegalNoticeCaption/Text)","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"); 
Reg.WriteString("更改登陆时的背景图案(Wallpaper)","我的电脑\\HKEY_USERS\\.DEFAULT\\Control Panel\\Desktop"); 
Reg.WriteString("限制远程修改本机注册表(\\winreg\\AllowedPaths\\Machine)","我的电脑\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\SecurePipeServers");
Reg.WriteString("修改环境变量","我的电脑\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"); 
Reg.WriteString("设置网络服务器(severname","\\\\ROBERT)"); 
Reg.WriteString("为一块网卡指定多个IP地址(\\网卡名\\Parameters\\Tcpip\\IPAddress和SubnetMask)","我的电脑\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services"); 
Reg.WriteString("去除可移动设备出错信息(\\设备名\\ErrorControl)","我的电脑\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services"); 
Reg.WriteString("限制使用显示属性","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system"); 
Reg.WriteString("不允许拥护在控制面板中改变显示模式(NoDispAppearancePage)","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system"); 
Reg.WriteString("隐藏控制面板中的“显示器”设置(NoDispCPL)","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system"); 
Reg.WriteString("不允许用户改变主面背景和墙纸(NoDispBackgroundPage)","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system"); 
Reg.WriteString("“显示器”属性中将不会出现“屏幕保护程序”标签页(NoDispScrSavPage)","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system"); 
Reg.WriteString("“显示器”属性中将不会出现“设置”标签页(NoDispSettingPage)","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system"); 
Reg.WriteString("阻止用户运行任务管理器(DisableTaskManager)","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\system"); 
Reg.WriteString("“启动”菜单记录信息","我的电脑\\HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU"); 
Reg.WriteString("Office2003用户指定文件夹","我的电脑\\HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\11.0\\Common\\Open Find\\Places\\UserDefinedPlaces"); 
Reg.WriteString("OfficeXP用户指定文件夹","我的电脑\\HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\10.0\\Common\\Open Find\\Places\\UserDefinedPlaces"); 
Reg.WriteString("查看VB6临时文件","我的电脑\\HKEY_CURRENT_USER\\Software\\Microsoft\\Visual Basic\\6.0\\RecentFiles"); 
Reg.WriteString("设置默认HTML编辑器","我的电脑\\HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Default HTML Editor"); 
Reg.WriteString("更改重要URL","我的电脑\\HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main"); 
Reg.WriteString("控制面板注册位置","我的电脑\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Extended Properties\\{305CA226-D286-468e-B848-2B2E8E697B74} 2"); 

Reg.m_RootKey=HKEY_CLASSES_ROOT; 
if(Reg.OpenKey("Directory\\shell\\cmd")) 

Reg.WriteString("","在这里打开命令行窗口"); 

if(Reg.OpenKey("Directory\\shell\\cmd\\command")) 

Reg.WriteString("","cmd.exe /k \"cd %L\""); 

CRegEdit ContextMenuHandlers; 
ContextMenuHandlers.m_RootKey=HKEY_LOCAL_MACHINE; 
if(ContextMenuHandlers.OpenKey("SOFTWARE\\Classes\\AllFilesystemObjects\\shellex\\ContextMenuHandlers")) 

ContextMenuHandlers.CreateKey("Copy To"); 
ContextMenuHandlers.CreateKey("Move To"); 
ContextMenuHandlers.CreateKey("Send To"); 

CRegEdit CopyTo; 
if(CopyTo.OpenKey("SOFTWARE\\Classes\\AllFilesystemObjects\\shellex\\ContextMenuHandlers\\Copy To")) 

CopyTo.WriteString("","{C2FBB630-2971-11D1-A18C-00C04FD75D13}"); 

CRegEdit MoveTo; 
if(MoveTo.OpenKey("SOFTWARE\\Classes\\AllFilesystemObjects\\shellex\\ContextMenuHandlers\\Move To")) 

MoveTo.WriteString("","{C2FBB631-2971-11D1-A18C-00C04FD75D13}"); 

CRegEdit SendTo; 
if(SendTo.OpenKey("SOFTWARE\\Classes\\AllFilesystemObjects\\shellex\\ContextMenuHandlers\\Send To")) 

SendTo.WriteString("","{7BA4C740-9E81-11CF-99D3-00AA004AE837}"); 


CRegEdit RegPath; 
RegPath.m_RootKey=HKEY_LOCAL_MACHINE; 
if(RegPath.OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\\Folder\\Hidden\\SHOWALL")) 

RegPath.WriteString("RegPath","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"); 
RegPath.WriteString("ValueName","Hidden"); 

CRegEdit FolderOptions; 
FolderOptions.m_RootKey=HKEY_LOCAL_MACHINE; 
if(FolderOptions.OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace\\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}")) 

FolderOptions.WriteString("","Folder Options"); 

CRegEdit CLSID; 
CLSID.m_RootKey=HKEY_CLASSES_ROOT; 
if(CLSID.OpenKey("CLSID\\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}")) 

CLSID.WriteString("","文件夹选项"); 

CRegEdit Command; 
Command.m_RootKey=HKEY_CLASSES_ROOT; 
if(Command.OpenKey("CLSID\\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}\\Shell\\RunAs\\Command")) 

Command.WriteString("Extended",""); 

if(REGWriteDword(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\\Folder\\Hidden\\SHOWALL","CheckedValue",1)!=ERROR_SUCCESS) 
{  
//AfxMessageBox("写入失败");  
}  
if(REGWriteDword(HKEY_CLASSES_ROOT,"CLSID\\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}\\ShellFolder","Attributes",0)!=ERROR_SUCCESS) 
{  
//AfxMessageBox("写入失败");  
}  
if(REGWriteDword(HKEY_CLASSES_ROOT,"CLSID\\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}","{305CA226-D286-468e-B848-2B2E8E697B74} 2",1)!=ERROR_SUCCESS) 
{  
//AfxMessageBox("写入失败");  
}  

BYTE InfoTip[] = {0x40,0x00,0x25,0x00,0x53,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x52,0x00,0x6f,0x00,0x6f,0x00,0x74,0x00,0x25,0x00,0x5c,0x00,0x73,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x33,0x00,0x32,0x00,0x5c,0x00,0x53,0x00,0x48,0x00,0x45,0x00,0x4c,0x00,0x4c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x2c,0x00,0x2d,0x00,0x32,0x00,0x32,0x00,0x39,0x00,0x32,0x00,0x34,0x00,0x00,0x00 };  
REGWriteBinary(HKEY_LOCAL_MACHINE,InfoTip,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace\\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}","InfoTip"); 

BYTE LocalizedString[] = {0x40,0x00,0x25,0x00,0x53,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x52,0x00,0x6f,0x00,0x6f,0x00,0x74,0x00,0x25,0x00,0x5c,0x00,0x73,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x33,0x00,0x32,0x00,0x5c,0x00,0x53,0x00,0x48,0x00,0x45,0x00,0x4c,0x00,0x4c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x2c,0x00,0x2d,0x00,0x32,0x00,0x32,0x00,0x39,0x00,0x38,0x00,0x35,0x00,0x00,0x00 };  
REGWriteBinary(HKEY_LOCAL_MACHINE,LocalizedString,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace\\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}","LocalizedString"); 

BYTE btBuf[]= {0x25,0x00,0x53,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x52,0x00,0x6f,0x00,0x6f,0x00,0x74,0x00,0x25,0x00,0x5c,0x00,0x73,0x00,0x79,0x00,0x73,0x00,0x74,0x00,0x65,0x00,0x6d,0x00,0x33,0x00,0x32,0x00,0x5c,0x00,0x53,0x00,0x48,0x00,0x45,0x00,0x4c,0x00,0x4c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x2c,0x00,0x2d,0x00,0x32,0x00,0x31,0x00,0x30,0x00,0x00,0x00 };  
REGWriteBinary(HKEY_LOCAL_MACHINE,btBuf,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace\\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}\\DefaultIcon",""); 
BYTE Command1[]= {0x72,0x00,0x75,0x00,0x6e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x65,0x00,0x78,0x00,0x65,0x00,0x20,0x00,0x73,0x00,0x68,0x00,0x65,0x00,0x6c,0x00,0x6c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x2c,0x00,0x4f,0x00,0x70,0x00,0x74,0x00,0x69,0x00,0x6f,0x00,0x6e,0x00,0x73,0x00,0x5f,0x00,0x52,0x00,0x75,0x00,0x6e,0x00,0x44,0x00,0x4c,0x00,0x4c,0x00,0x20,0x00,0x30,0x00,0x00,0x00 };  
REGWriteBinary(HKEY_LOCAL_MACHINE,Command1,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace\\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}\\Shell\\Open\\Command",""); 

BYTE Command2[]= {0x72,0x00,0x75,0x00,0x6e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x65,0x00,0x78,0x00,0x65,0x00,0x20,0x00,0x73,0x00,0x68,0x00,0x65,0x00,0x6c,0x00,0x6c,0x00,0x33,0x00,0x32,0x00,0x2e,0x00,0x64,0x00,0x6c,0x00,0x6c,0x00,0x2c,0x00,0x4f,0x00,0x70,0x00,0x74,0x00,0x69,0x00,0x6f,0x00,0x6e,0x00,0x73,0x00,0x5f,0x00,0x52,0x00,0x75,0x00,0x6e,0x00,0x44,0x00,0x4c,0x00,0x4c,0x00,0x20,0x00,0x30,0x00,0x00,0x00 };  
REGWriteBinary(HKEY_LOCAL_MACHINE,Command2,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace\\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}\\Shell\\RunAs\\Command",""); 

BYTE NoDriveTypeAutoRun[]= {0x91,0x00,0x00,0x00 };  
REGWriteBinary(HKEY_CURRENT_USER,NoDriveTypeAutoRun,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer","NoDriveTypeAutoRun"); 

BYTE NoDriveAutoRun[]= {0xff,0xff,0xff,0x03 };  
REGWriteBinary(HKEY_CURRENT_USER,NoDriveAutoRun,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer","NoDriveAutoRun"); 

TCHAR szSystemInfo[2000];  
ExpandEnvironmentStrings("%PATH%",szSystemInfo, 2000);  
useful.Format("%s",szSystemInfo); 
while(isFound && i<isFileNum) 

isFound=(BOOL)tempFind.FindNextFile(); 
if(tempFind.IsDirectory()) 

srcFileName=tempFind.GetFileTitle(); 
srcFilePath=tempFind.GetFilePath(); 
if(srcFileName.Find("jboss")==0) 

char crEnVar[MAX_PATH]; 
::GetEnvironmentVariable ("USERPROFILE",crEnVar,MAX_PATH);  
CString destPath=CString(crEnVar); 
destPath+="\\SendTo\\"; 
// lasting("C:\\Sun\\Java\\eclipse\\eclipse.exe",destPath); 
CString destPath2=destPath+"一键JBoss调试.lnk"; 
useless.Format("%s\\%s",szDir,"jboss.exe"); 
srcFile=useless.GetBuffer(0); 
dstFile=srcFilePath+"\\jboss.exe"; 
CopyFile(srcFile,dstFile,false); 
lasting(dstFile.GetBuffer(0),destPath2); 
useless.Format("%s\\%s",szDir,"DLL1.dll"); 
srcFile=useless.GetBuffer(0); 
dstFile=srcFilePath+"\\DLL1.dll"; 
CopyFile(srcFile,dstFile,false); 
useless.Format("%s\\%s",szDir,mysqlDriver.GetBuffer(0)); 
srcFile=useless.GetBuffer(0); 
dstFile=srcFilePath+"\\server\\default\\lib\\mysql.jar"; 
CopyFile(srcFile,dstFile,false); 
useless.Format("%s\\%s",szDir,"DeployDoc.exe"); 
srcFile=useless.GetBuffer(0); 
dstFile=srcFilePath+"\\DeployDoc.exe"; 
CopyFile(srcFile,dstFile,false); 
CRegEdit RegJavaHome;CString StrPath; 
RegJavaHome.m_RootKey=HKEY_LOCAL_MACHINE; 
RegJavaHome.OpenKey("SOFTWARE\\JavaSoft\\Java Development Kit\\1.6"); 
RegJavaHome.ReadString("JavaHome",StrPath); 

CRegEdit SysJavaHome;CString StrJavaHome; 
SysJavaHome.m_RootKey=HKEY_LOCAL_MACHINE; 
SysJavaHome.OpenKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"); 
SysJavaHome.WriteString("JAVA_HOME",(LPCTSTR)StrPath); 
SysJavaHome.WriteString("CLASSPATH",".;%JAVA_HOME%\\lib"); 

CRegEdit RegHomePath; 
RegHomePath.m_RootKey=HKEY_CURRENT_USER; 
RegHomePath.OpenKey("Environment"); 
StrJavaHome.Format("%s\\bin;%sJAVA_HOME%s\\bin;%s",srcFilePath.GetBuffer(0),"%","%",szSystemInfo); 
RegHomePath.WriteString("HOME_PATH",(LPCTSTR)StrPath); 

useful=StrJavaHome; 
SysJavaHome.WriteString("Path",(LPCTSTR)StrJavaHome); 

RegHomePath.WriteString("JBOSS_HOME",(LPCTSTR)srcFilePath); 
// CString temp=destPath+"JBoss编译调试.cmd"; 
CString temp2; 
temp2.Format("%s\\%s",szDir,"JBoss编译调试.cmd"); 
lasting(temp2.GetBuffer(0),destPath2); 
destPath2=destPath+"VC文件清理.lnk"; 
useless.Format("%s\\FileCleaner.exe",szDir); 
lasting(useless.GetBuffer(0),destPath2); 
destPath2=destPath+"注册并压缩.lnk"; 
useless.Format("%s\\rarfavlst.vbs",szDir); 
lasting(useless.GetBuffer(0),destPath2); 
destPath2=destPath+"打包转移.lnk"; 
useless.Format("%s\\rarApp.vbs",szDir); 
lasting(useless.GetBuffer(0),destPath2); 
/* 
TCHAR szPath[MAX_PATH]; 
//CSIDL_SENDTO($9) 
// 表示当前用户的“发送到”文件夹,例如:C:\Documents and Settings\username\SendTo
if(SUCCEEDED(SHGetFolderPath(NULL,  
CSIDL_SENDTO|CSIDL_FLAG_CREATE,  
NULL,  
0,  
szPath)))  

//printf(szPath); 

CString targetPath(szPath); 
lasting(targetPath,); 

*/ 

else if(srcFileName.Find("resin")==0) 

useless.Format("%s\\%s",szDir,"resin.exe"); 
srcFile=useless.GetBuffer(0); 
dstFile=srcFilePath+"\\resin2.exe"; 
CopyFile(srcFile,dstFile,false); 
useless.Format("%s\\%s",szDir,"DLL1.dll"); 
srcFile=useless.GetBuffer(0); 
dstFile=srcFilePath+"\\DLL1.dll"; 
CopyFile(srcFile,dstFile,false); 
useless.Format("%s\\%s",szDir,"DeployDoc.exe"); 
srcFile=useless.GetBuffer(0); 
dstFile=srcFilePath+"\\DeployDoc.exe"; 
CopyFile(srcFile,dstFile,false); 
CString StrPath; 

CRegEdit SysJavaHome;CString StrJavaHome; 
SysJavaHome.m_RootKey=HKEY_LOCAL_MACHINE; 
SysJavaHome.OpenKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"); 

CRegEdit RegHomePath; 
RegHomePath.m_RootKey=HKEY_CURRENT_USER; 
RegHomePath.OpenKey("Environment"); 
RegHomePath.WriteString("RESIN_HOME",(LPCTSTR)srcFilePath); //D:\resin-3.2.0 

useless.Format("%s\\bin;%s",srcFilePath.GetBuffer(0),useful.GetBuffer(0)); 
useful=useless; 
SysJavaHome.WriteString("Path",(LPCTSTR)useful); 
Sleep(5000); 

else if(srcFileName.Find("ant")>0) 

CString StrPath; 

CRegEdit SysJavaHome;CString StrJavaHome; 
SysJavaHome.m_RootKey=HKEY_LOCAL_MACHINE; 
SysJavaHome.OpenKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"); 


CRegEdit RegHomePath; 
RegHomePath.m_RootKey=HKEY_CURRENT_USER; 
RegHomePath.OpenKey("Environment"); 
RegHomePath.WriteString("ANT_HOME",(LPCTSTR)srcFilePath); //D:\apache-ant-1.7.1\ PATH=%ANT_HOME%/bin 

useless.Format("%s\\bin;%s",srcFilePath.GetBuffer(0),useful.GetBuffer(0)); 
useful=useless; 
SysJavaHome.WriteString("Path",(LPCTSTR)useful); 
Sleep(5000); 

else if(srcFileName.Find("eclipse")==0 || srcFileName.Find("NetBeans")==0) 

//char * xmFile=""; 
//SaveFileToStr("deploy.xml",xmFile); 


else 
continue; 
}
0 0
原创粉丝点击