请问在VC中怎样打开一个任意类型的文件(只读方式),然后显示出来,后续的关闭操作不用管?
解决方案 »
- 飞信2011重写了?
- 我在窗体A声明了一个类对象,怎么在窗体B调用?
- IE 插件 死循环并能保证循环外的代码被执行
- 禁止一个实例多次运行?
- 请问如何实现工作区的图形的点选。急急。亲爱的同志来,进来吧。
- 好久没来MFC了 ... 散分 200 ,问个老问题 : 工资
- 讀取文本文件裏面的内容。(文本文件裏面的數據格式有一定規律,具體請進來看),請問程序如何寫。
- 调用:reTranslateMessage时为什么提示:illegal call of non-static member function
- HBRUSH hbr如何初始化!!??
- 高手指教,并且发布一个没用的程序,欢迎up,gz
- 地图编辑器是怎么做的?
- 快疯了!socket怎么用不了???(50分)在线等!
CStdioFile file;
file.Open("c:\\test.xxx",CFile::ModeRead);
CString temp;
while(file.GetString(temp))
{
pDC->TextOut(temp);
}上面是大概流程,具体函数参数自己查一下
{
FILE *stream;
char list[30];
int i, numread, numwritten; /* Open file in text mode: */
if( (stream = fopen( "fread.out", "w+t" )) != NULL )
{
for ( i = 0; i < 25; i++ )
list[i] = (char)('z' - i);
/* Write 25 characters to stream */
numwritten = fwrite( list, sizeof( char ), 25, stream );
printf( "Wrote %d items\n", numwritten );
fclose( stream ); }
else
printf( "Problem opening the file\n" ); if( (stream = fopen( "fread.out", "r+t" )) != NULL )
{
/* Attempt to read in 25 characters */
numread = fread( list, sizeof( char ), 25, stream );
printf( "Number of items read = %d\n", numread );
printf( "Contents of buffer = %.25s\n", list );
fclose( stream );
}
else
printf( "File could not be opened\n" );
}
我打开文件的目的是给用户看,可以说是一个*.HLP文件,我不想使用MFC中的创建工程是自带的F1帮助功能来打开,还有其他的方法来打开吗?然后显示出来。功能类似用户直接打开了一个*.HLP文件。
可以用系统默认的程序打开任何文件.
详细查MSDN.