**************************************一个文件中存储了所有的文件,他们的数据是如何存储的?**************************************

ProgramInHeart 2005-06-16 05:16:16
网上有很多资料管理软件

将所有的数据都有顺序的存储了一个文件中

如果某天的资料包含有:文本文件 JPEG图片 Mp3文件 ........可以包含所有任意文件
每个文件都有一个id
程序运行时会读出所有文件的id
当双击ID时(比如显示在TreeCtrl中)
会用相应的软件打开对应的文件(如:如果装了winamp双击.mp3文件的ID时会用winamp播放文件)这些文件都是存储在一个大文件中的

这些数据是怎么存储的?

你们做过相关东东吗?
给我点意见

有源码吗?只要源码够好,我还有几百分全给你
为了解决问题,参与就有分
...全文
150 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
ProgramInHeart 2005-06-17
  • 打赏
  • 举报
回复
ini里面怎么放.exe文件、安装程序、mp3文件呢?

我是说,把文件放在里面,不是把文件的path放里面

其实就确实和winrar差不多,网上有很多资料管理的软件都是用一个大文件存储所有的文件的
leechiyang 2005-06-17
  • 打赏
  • 举报
回复
qrlvls(空 气)
--------------
>使用结构化存储,通过结构化存储可以象访问一个目录一样访问一个文件

这是正解,速度还是蛮不错的。

artmouse(艺术老鼠)
-----------------------
>别的我不知道,但是我觉得xml可以这样存文件,对于二进制的,编码为base64

如果内容不多,文件不大,此法也不错,简单便捷。
还可以用INI文件保存更简单些。
artmouse 2005-06-16
  • 打赏
  • 举报
回复
别的我不知道,但是我觉得xml可以这样存文件,对于二进制的,编码为base64
qrlvls 2005-06-16
  • 打赏
  • 举报
回复
可以参考 MSDN 2003 中的
ms-help://MS.MSDNQTR.2003APR.1033/stg/stg/enumall_sample.htm
ProgramInHeart 2005-06-16
  • 打赏
  • 举报
回复

https://sourceforge.net/projects/sevenzip/


高难
qrlvls 2005-06-16
  • 打赏
  • 举报
回复
使用结构化存储,通过结构化存储可以象访问一个目录一样访问一个文件
Office 的文件便是基于结构化存储的
To build:
// cl /GX WriteRead.cpp
//
//+============================================================================


#define WIN32_LEAN_AND_MEAN
#define UNICODE
#define _UNICODE

#include <stdio.h>
#include <windows.h>
#include <ole2.h>

// Implicitly link ole32.dll
#pragma comment( lib, "ole32.lib" )


// From uuidgen.exe:
const FMTID fmtid = { /* d170df2e-1117-11d2-aa01-00805ffe11b8 */
0xd170df2e,
0x1117,
0x11d2,
{0xaa, 0x01, 0x00, 0x80, 0x5f, 0xfe, 0x11, 0xb8}
};


EXTERN_C void wmain()
{
HRESULT hr = S_OK;
IPropertySetStorage *pPropSetStg = NULL;
IPropertyStorage *pPropStg = NULL;
WCHAR *pwszError = L"";

try
{

// Create a file and a property set within it.

hr = StgCreateStorageEx( L"WriteRead.stg",
STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE,
STGFMT_STORAGE,
// STGFMT_STORAGE => Structured Storage property sets
// STGFMT_FILE => NTFS file system property sets
0, NULL, NULL,
IID_IPropertySetStorage,
reinterpret_cast<void**>(&pPropSetStg) );
if( FAILED(hr) ) throw L"Failed StgCreateStorageEx";

hr = pPropSetStg->Create( fmtid, NULL, PROPSETFLAG_DEFAULT,
STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE,
&pPropStg );
if( FAILED(hr) ) throw L"Failed IPropertySetStorage::Create";

// Write a Unicode string property to the property set

propspec.ulKind = PRSPEC_LPWSTR;
propspec.lpwstr = L"Property Name";

propvarWrite.vt = VT_LPWSTR;
propvarWrite.pwszVal = L"Property Value";

hr = pPropStg->WriteMultiple( 1, &propspec, &propvarWrite, PID_FIRST_USABLE );
if( FAILED(hr) ) throw L"Failed IPropertyStorage::WriteMultiple";

// It's not required, but give the property set a friendly name.

PROPID propidDictionary = PID_DICTIONARY;
WCHAR *pwszFriendlyName = L"Write/Read Properties Sample Property Set";
hr = pPropStg->WritePropertyNames( 1, &propidDictionary, &pwszFriendlyName );
if( FAILED(hr) ) throw L"Failed IPropertyStorage::WritePropertyNames";

// Close and reopen everything.
// By using the STGFMT_ANY flag in the StgOpenStorageEx call,
// it doesn't matter if this is a Structured Storage property
// set or an NTFS file system property set (see the StgCreateStorageEx call
// above).

pPropStg->Release(); pPropStg = NULL;
pPropSetStg->Release(); pPropSetStg = NULL;

hr = StgOpenStorageEx( L"WriteRead.stg",
STGM_READ|STGM_SHARE_DENY_WRITE,
STGFMT_ANY,
0, NULL, NULL,
IID_IPropertySetStorage,
reinterpret_cast<void**>(&pPropSetStg) );
if( FAILED(hr) ) throw L"Failed StgOpenStorageEx";

hr = pPropSetStg->Open( fmtid, STGM_READ|STGM_SHARE_EXCLUSIVE,
&pPropStg );
if( FAILED(hr) ) throw L"Failed IPropertySetStorage::Open";

// Read the property back and validate it

hr = pPropStg->ReadMultiple( 1, &propspec, &propvarRead );
if( FAILED(hr) ) throw L"Failed IPropertyStorage::ReadMultiple";

if( S_FALSE == hr )
throw L"Property didn't exist after reopening the property set";
else if( propvarWrite.vt != propvarRead.vt )
throw L"Property types didn't match after reopening the property set";
else if( 0 != wcscmp( propvarWrite.pwszVal, propvarRead.pwszVal ))
throw L"Property values didn't match after reopening the property set";
else
wprintf( L"Success\n" );

}
catch( const WCHAR *pwszError )
{
wprintf( L"Error: %s (hr=%08x)\n", pwszError, hr );
}

PropVariantClear( &propvarRead );
if( pPropStg ) pPropStg->Release();
if( pPropSetStg ) pPropSetStg->Release();

}

fireseed 2005-06-16
  • 打赏
  • 举报
回复
关于TreeCtrl的问题你试一下下面的代码:
BOOL CMainFrame::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
NMHDR *pHdr = (NMHDR*)lParam;
if(pHdr->idFrom==0x1005)
{
AfxMessageBox("ID");

}
if(wParam==NM_RCLICK)
{
AfxMessageBox("MSG");

}
return CFrameWnd::OnNotify(wParam, lParam, pResult);
}
fireseed 2005-06-16
  • 打赏
  • 举报
回复
现在全球最好的开源压缩工具在:
https://sourceforge.net/projects/sevenzip/

源代码、程序都有,楼主自己下吧,就是实现了你要的功能
fireseed 2005-06-16
  • 打赏
  • 举报
回复
你是说wParam永远不等于NM_RCLICK吗?怎么可能
ProgramInHeart 2005-06-16
  • 打赏
  • 举报
回复
借用自家宝地

to:fireseed(奶油狗【Dream of violin】)
CTreeCtrl控件
这个条件为什么不起作用?虽然编译没有错

BOOL CMainFrame::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
NMHDR *pHdr = (NMHDR*)lParam;
if(pHdr->idFrom==0x1005 && wParam==NM_RCLICK)
{
AfxMessageBox("aaa");

}
return CFrameWnd::OnNotify(wParam, lParam, pResult);
}

wParam==NM_RCLICK这个条件不起作用

=============================================================
上面的数据是如何存储的?
ProgramInHeart 2005-06-16
  • 打赏
  • 举报
回复
对就是类似的东西,谁有代码???
truewill 2005-06-16
  • 打赏
  • 举报
回复
呵呵iso也行
ProgramInHeart 2005-06-16
  • 打赏
  • 举报
回复
怎么又是你,我的分都让你得去了
fireseed 2005-06-16
  • 打赏
  • 举报
回复
靠,楼主,又是你
fireseed 2005-06-16
  • 打赏
  • 举报
回复
winzip和winrar楼主见过吗?

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧