代码如下:
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
int nPos;
nPos=sPath.ReverseFind ('\\');
sPath=sPath.Left (nPos);
CFile f;
CFileException e;
CString tpath=sPath+"\\sys1.sys";
char * pathtotal;
pathtotal=new char[tpath.GetLength()];for(int ii=0;ii<tpath.GetLength();ii++)
pathtotal[ii]=tpath.GetAt(ii); char* pFileName =pathtotal;
if( !f.Open( pFileName, CFile::modeRead, &e ) )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e.m_cause << "\n";
#endif
}
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
int nPos;
nPos=sPath.ReverseFind ('\\');
sPath=sPath.Left (nPos);
CFile f;
CFileException e;
CString tpath=sPath+"\\sys1.sys";
char * pathtotal;
pathtotal=new char[tpath.GetLength()];for(int ii=0;ii<tpath.GetLength();ii++)
pathtotal[ii]=tpath.GetAt(ii); char* pFileName =pathtotal;
if( !f.Open( pFileName, CFile::modeRead, &e ) )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e.m_cause << "\n";
#endif
}
解决方案 »
- 多视图显示问题,创建一个类似于VC++6.0那种左边有个工作列表的窗口(求高手指点,不甚感激!)
- 使用WINIO模拟按键时鼠标为什么会乱跑
- 不用if/else怎么调用函数
- 怎么把汉字转换成URL编码
- VC6内嵌汇编的问题
- CMultiDocTemplate* pDocTemplate;的疑惑?
- (急)如何用matlab或VC实现用小波变换方法提取图像边缘?
- 如何在运行中更改非模态对话框上控件的caption属性?
- 弹出的菜单,去不掉怎么办?用Findwindow找到这个菜单的窗口 句柄 ,再exit它,有没有用?
- 请问一下这几个东西怎么画?
- 一个基础的理论问题
- 散分了,谁能给我一些线程的资料的话
GetModuleFileName( NULL, szFilePath, MAX_PATH );
char * p = strrchr( szFilePath, '\\' ) + 1;
if( p != NULL ) *p = 0;
strcat( szFilePath, "sys1.sys" );
if( !f.Open( szFilePath, CFile::modeRead ) )
{
}
//当然,如果sys1.sys正在被使用,就可能打不开。
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
int nPos;
nPos=sPath.ReverseFind ('\\');
sPath=sPath.Left (nPos);
CFile f;
CFileException e;
CString tpath=sPath+"\\sys1.sys";
sPath.ReleaseBuffer ();
char * pathtotal;
pathtotal=new char[tpath.GetLength()];for(int ii=0;ii<tpath.GetLength();ii++)
pathtotal[ii]=tpath.GetAt(ii);pathtotal[ii]=0; char* pFileName =pathtotal;
if( !f.Open( pFileName, CFile::modeRead, &e ) )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e.m_cause << "\n";
#endif
}