TCHAR m_Path[MAX_PATH];
GetModuleFileName( NULL, m_Path, MAX_PATH ); //获取程序路径(包括程序名)
int i = 0, j;
while( m_Path[i]!=0 )
{
if( m_Path[i]=='\' )
j = i;
i++;
}
m_Path[j+1] = '';
m_exePath.Format( "%s", m_Path ); //分离路径名(去掉程序名)
CFile file; file.Open( m_exePath+"数据文件名", CFile::modeRead );
CFile file; file.Open( m_exePath+"临时文件名", CFile::modeCreate | CFile::modeWrite ); ……
CFile::Remove( m_exePath+"临时文件名" );
WinExec(m_PathName,SW_SHOWNORMAL);
WinExec("C:\Program Files\Internet Explorer\iexplore.exe",SW_SHOWNORMAL);//为打开IE浏览器
ShellExecute(NULL,NULL,m_PathName,NULL,_T("c:\temp"),SW_SHOWNORMAL);
//退出程序
BOOL CEditDoc::CanCloseFrame(CFrameWnd* pFrame)
{
CFile file;
if(b_Flag) //b_Flag为文档修改标志,在修改文档时将其置为True
{
int t;
t=::MessageBox(NULL,"文字已经改变,要存盘吗?","警告",
MB_YESNOCANCEL | MB_ICONWARNING); //弹出提示对话框
if(t==0 || t==IDCANCEL)
return false;
if(t==IDYES)
{
CString sFilter="Text File(*.txt)|*.txt||";
CFileDialog m_Dlg(FALSE,"txt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,(LPCTSTR)sFilter,NULL); //定制文件对话框
int k=m_Dlg.DoModal(); //弹出文件对话框
if(k==IDCANCEL || k==0)
return false;
m_PathName=m_Dlg.GetPathName(); //获取选择的文件路径名
file.Open(m_PathName,CFile::modeCreate | CFile::modeWrite);
file.Write(m_Text,m_TextLen); //数据写入文件
file.Close();
}
}
return CDocument::CanCloseFrame(pFrame);
}
POSITION pos; //定义pos型变量
pos = GetHeadPosition(); //获取列表起始元素位置
while( pos )
{
x = GetNext(pos); //获取pos处的列表值,同时修改pos为下一个元素位置
}
TYPE GetNext(POSITION& rPosition);
POSITION Find(TYPE Value);//用于在列表中查找值为Value的元素的POSITION值; POSITION FindIndex(int nIndex);//用于获取列表中第nIndex个元素的POSITION值,nIndex从0开始。
pos = FindIndex(5); //求列表中第5个元素的位置 x = GetNext(pos); //读取元素的值
CString GetFileName(CString pathname)
{
for( int i=pathname.GetLength()-1; i>=0; i-- )
{
if( pathname[i]=='\' )
break;
}
return pathname.Mid( i+1 );
}
CString GetPath(CString pathname)
{
int i = 0, j;
while( i<pathname.GetLength() )
{
if( pathname[i]=='\' )
j = i;
i++;
}
return pathname.Left( j+1 );
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有