CFile...

CFile对象使用与JavaScript技巧
博客记录了学习成果,包括MFC里CFile对象的文件读写方法、C++ I/O方法,还提及JavaScript使用技巧。介绍了CFile对象生成、打开及读取操作,同时给出清除IE历史记录的函数代码。

今天学会了CFile对象,原来MFC里面文件读写的方法有那么多的。还有用C++I/O的方法的。

不过,文档/视图类的交互,还有CFileDialog和做成文件读写的程序还没有.

另外,读取网络内容变成控件的内容也要学学...

还有,今天也知道了JavaScript的一些使用技巧。呵呵...

重要的是CFile的对象生成(lpszFileName),然后用CFile::Open来打开,再建立一个char的数组缓冲区,用CFile::Read来将读到的Byte放进去。

用.和用->是差不多的,不过一个是指针(->& *),一个没有而已(.)。

这个问题还要弄明白!!!

-------------------------------

清除IE的历史记录的函数
#include <wininet.h>
#include <UrlHist.h>
#include <shlguid.h>
#include <objbase.h>

ClearHistory()
{
CoInitialize(NULL);
IUrlHistoryStg2 *pUrlHistoryStg2 = NULL;
HRESULT hr = CoCreateInstance(CLSID_CUrlHistory,NULL,1,IID_IUrlHistoryStg2,(LPVOID *)&pUrlHistoryStg2);
if(SUCCEEDED(hr))
{
pUrlHistoryStg2->ClearHistory();
pUrlHistoryStg2->Release();
}
CoUninitialize();
}

----------------------------------------

CFile Class Members

Data Members

m_hFileUsually contains the operating-system file handle.

Construction

CFileConstructs a CFile object from a path or file handle.
AbortCloses a file ignoring all warnings and errors.
DuplicateConstructs a duplicate object based on this file.
OpenSafely opens a file with an error-testing option.
CloseCloses a file and deletes the object.

Input/Output

ReadReads (unbuffered) data from a file at the current file position.
ReadHugeCan read more than 64K of (unbuffered) data from a file at the current file position. Obsolete in 32-bit programming. See Read.
WriteWrites (unbuffered) data in a file to the current file position.
WriteHugeCan write more than 64K of (unbuffered) data in a file to the current file position. Obsolete in 32-bit programming. See Write.
FlushFlushes any data yet to be written.

Position

SeekPositions the current file pointer.
SeekToBeginPositions the current file pointer at the beginning of the file.
SeekToEndPositions the current file pointer at the end of the file.
GetLengthRetrieves the length of the file.
SetLengthChanges the length of the file.

Locking

LockRangeLocks a range of bytes in a file.
UnlockRangeUnlocks a range of bytes in a file.

Status

GetPositionRetrieves the current file pointer.
GetStatusRetrieves the status of this open file.
GetFileNameRetrieves the filename of the selected file.
GetFileTitleRetrieves the title of the selected file.
GetFilePathRetrieves the full file path of the selected file.
SetFilePathSets the full file path of the selected file.

Static

RenameRenames the specified file (static function).
RemoveDeletes the specified file (static function).
GetStatusRetrieves the status of the specified file (static, virtual function).
SetStatusSets the status of the specified file (static, virtual function).
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值