viewer.cpp
上传用户:bjlvip
上传日期:2010-02-08
资源大小:744k
文件大小:1k
- #include <windows.h>
- #include <iostream.h>
- void main(int argc, char** argv)
- {
- CoInitialize(NULL);
- IStorage* pStorage;
- HRESULT hr = StgOpenStorage(L"C:\TestFile.STG", NULL, STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, NULL, &pStorage);
- if(FAILED(hr))
- {
- cout << "StgOpenStream failed: Run PropertyStreams first" << endl;
- exit(0);
- }
- IEnumSTATSTG* pEnumerator;
- pStorage->EnumElements(NULL, NULL, NULL, &pEnumerator);
- STATSTG myStat;
- ULONG how_many;
- while(true)
- {
- pEnumerator->Next(1, &myStat, &how_many);
- if(how_many == 0)
- break;
- char buffer[255];
- WideCharToMultiByte(CP_ACP, 0, myStat.pwcsName, -1, buffer, 255, NULL, NULL);
- switch(myStat.type)
- {
- case STGTY_STORAGE:
- cout << buffer << " is a " << "storage" << endl;
- case STGTY_STREAM:
- cout << buffer << " is a " << "stream" << endl;
- }
- }
- pEnumerator->Release();
- pStorage->Release();
- CoUninitialize();
- }