Title: How to create a structured storage file Part 1
Question: What to know how to create a structured storage file.
No more need to distribute a BDE with this baby..
Answer:
ShellSPY V1.1a
is the award winning and powerful monitoring solution that you need! ShellSPY
gives you the power to log all keystrokes, windows viewed, applications ran, internet
connections made, passwords entered, chat conversations that were made, Monitor
all running tasks on your pc Download
Now
Web Site:
Cjpsoftware.com
// Structured Storage is applicable to Microsoft COM-based operating systems:
// Windows XP, Windows 2000, Windows NT 4.0 or later, Windows Millennium
// Edition (Me), Windows 98, and Windows 95.
//
//Structured Storage provides file and data persistence in COM by treating
//a .single file as a structured collection of objects known as storages and
//streams.
//The purpose of Structured Storage is to reduce the performance penalties and
//overhead associated with storing separate objects in a single file.
//Structured Storage provides a solution by defining how to treat a single file
//entity as a structured collection of two types of objectsstorages and
//streamsthrough a standard implementation called Compound Files. This lets
//the user interact with and manage a compound file as if it were a single file
//rather than a nested hierarchy of separate objects.
// Microsoft provide all the objects required for sturctured storage
// preloaded with every copy of windows.
// So take advantage of this..
// The performance of sturctured storage is excellent.
// You can also store blob or bitmaps.
// If you want this project zipped drop me a email.
// Part 1 of how to create a storage file
//=======================================
// SSF := Structured Storage File..
// StgOpenStorage
// This command will open an existing ss.
// If it doesn`t exists the command StgCreateDocFile
// will create the file..
// CreateStream.
// We now need to create a stream. Ive called my stream index.
// And save data to the stream.
// In this project Ive saved the contents of myvalue.
// Whats a stream.
// This resides within the ss.
// You can create as many streams as you like.
// This project will create a file sh.ss take a look at it..
// IF you want part 2 now send me an email..
// Part 2 will contain how to read the data
// part 3 will contain how to buld a data structure based on Tcollection.
// part 4 will contain how to access the collection items..
// Part 5 will conatin problems I have had and resolved...
unit test;
interface
uses
Windows, Messages, SysUtils,activex,axctrls, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,comobj;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
FRootStorage: IStorage;
stm: IStream;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
strfile: PWideChar;
Myvalue: Integer;
BytesWritten: Longint;
begin
Strfile := 'sh.ss';
if not SUCCEEDED(StgOpenStorage(Strfile, nil,
STGM_READWRITE or STGM_SHARE_EXCLUSIVE,
nil, 0, FRootStorage)) then
Begin
StgCreateDocFile(strfile,
STGM_CREATE or STGM_READWRITE or STGM_SHARE_EXCLUSIVE,
0, FRootStorage);
FRootStorage.CreateStream('Index',
STGM_CREATE or STGM_READWRITE or STGM_SHARE_EXCLUSIVE, 0, 0, stm);
End;
Myvalue := 1000;
Olecheck(Stm.Write(@MyValue,sizeof(Integer),@BytesWritten));
end;
end.