IStorage
IStream
两个接口
IStream
两个接口
解决方案 »
- VC6.0下编写的Tool在Debug模式下没有问题,可是换成release运行就出错
- 有一个exe和内嵌IE控件交互的问题!
- 大家写VC++现在都用什么版本的开发工具
- 在菜单上多加一项目,想通过次项目关闭程序,因该怎么做
- ado 错误代码3077——请解释?!谢谢
- 关于opengl颜色改变问题!!求高手指教!!!
- 请问为何我在OnPrint()里用SetMapMode()设置打印模式无效。
- 请问在哪里可以下载 VisualAge for Java?
- mfc 让对话框在屏幕的上半部分显示
- 无模式对话框实例问题
- 问一下__declspec( dllimport ) 和__declspec( dllexport )各自的意思和区别
- windows2000的sniffer哪儿有
"存储"用IStorage进行操作
"流"用IStream进行操作建立文档用API:HRESULT StgCreateDocfile(
const WCHAR *pwcsName, //Pointer to path of compound file
// to create
DWORD grfMode, //Specifies the access mode for
// opening the storage object
DWORD reserved, //Reserved; must be zero
IStorage **ppstgOpen //Pointer to location for
// returning the new storage object
);最后一个参数将给出"根目录"的IStorage接口
然后利用此接口,可建立其下的"流"和"目录"
HRESULT CreateStream(
const WCHAR *pwcsName, //Pointer to the name of the new stream
DWORD grfMode, //Access mode for the new stream
DWORD reserved1, //Reserved; must be zero
DWORD reserved2, //Reserved; must be zero
IStream **ppstm //Pointer to new stream object
);HRESULT CreateStorage(
const WCHAR *pwcsName, //Pointer to the name of the new storage object
DWORD grfMode, //Access mode for the new storage object
DWORD reserved1, //Reserved; must be zero
DWORD reserved2, //Reserved; must be zero
IStorage **ppstg //Pointer to new storage object
);建立后,就能得到新建项的接口(ppstm和ppstg),进行下一级的操作
示例:
USES_CONVERSION;
//建立根"目录"
IStorage * p_root;
if( SUCCEEDED(StgCreateDocfile(T2COLE("testfilename"),
STGM_READWRITE| STGM_CREATE|STGM_SHARE_EXCLUSIVE
,0,&p_root)))
{
//建立根下的一个流
IStream *p_stream;
if(SUCCEEDED(p_root->CreateStream(T2COLE("rootstream"),
STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE ,
0,0,&p_stream)))
{
char *p="test";
DWORD writed;
p_stream->Write(p,4,&writed);
p_stream->Release();
}
p_root->Release(); }