1 |
// ***** BEGIN LICENSE BLOCK *****
|
2 |
// * Version: MPL 1.1
|
3 |
// *
|
4 |
// * The contents of this file are subject to the Mozilla Public License Version
|
5 |
// * 1.1 (the "License"); you may not use this file except in compliance with
|
6 |
// * the License. You may obtain a copy of the License at
|
7 |
// * http://www.mozilla.org/MPL/
|
8 |
// *
|
9 |
// * Software distributed under the License is distributed on an "AS IS" basis,
|
10 |
// * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
11 |
// * for the specific language governing rights and limitations under the
|
12 |
// * License.
|
13 |
// *
|
14 |
// * The Original Code is TurboPower SysTools
|
15 |
// *
|
16 |
// * The Initial Developer of the Original Code is
|
17 |
// * TurboPower Software
|
18 |
// *
|
19 |
// * Portions created by the Initial Developer are Copyright (C) 1996-2002
|
20 |
// * the Initial Developer. All Rights Reserved.
|
21 |
// *
|
22 |
// * Contributor(s):
|
23 |
// *
|
24 |
// * ***** END LICENSE BLOCK *****
|
25 |
//---------------------------------------------------------------------------
|
26 |
#include <vcl\vcl.h>
|
27 |
#pragma hdrstop
|
28 |
|
29 |
#include "exmmfsu.h"
|
30 |
#pragma link "ststrms"
|
31 |
//---------------------------------------------------------------------------
|
32 |
#pragma resource "*.dfm"
|
33 |
TForm1 *Form1;
|
34 |
//---------------------------------------------------------------------------
|
35 |
__fastcall TForm1::TForm1(TComponent* Owner)
|
36 |
: TForm(Owner)
|
37 |
{
|
38 |
}
|
39 |
//---------------------------------------------------------------------------
|
40 |
void __fastcall TForm1::btnOpenMMFClick(TObject *Sender)
|
41 |
{
|
42 |
|
43 |
try {
|
44 |
AMMFile = new TStMemoryMappedFile("", 100, false, true);
|
45 |
btnOpenMMF->Enabled = false;
|
46 |
btnCloseMMF->Enabled = true;
|
47 |
btnUpdate->Enabled = true;
|
48 |
}
|
49 |
catch (...) {
|
50 |
ShowMessage("Unable to create file");
|
51 |
}
|
52 |
|
53 |
}
|
54 |
//---------------------------------------------------------------------------
|
55 |
void __fastcall TForm1::btnCloseMMFClick(TObject *Sender)
|
56 |
{
|
57 |
delete AMMFile;
|
58 |
AMMFile = NULL;
|
59 |
btnOpenMMF->Enabled = true;
|
60 |
btnCloseMMF->Enabled = false;
|
61 |
btnUpdate->Enabled = false;
|
62 |
}
|
63 |
//---------------------------------------------------------------------------
|
64 |
void __fastcall TForm1::btnUpdateClick(TObject *Sender)
|
65 |
{
|
66 |
AnsiString S = Edit1->Text;
|
67 |
AMMFile->Seek(0, soFromBeginning);
|
68 |
StrPCopy(Buf, S);
|
69 |
AMMFile->Write(Buf, S.Length()+1);
|
70 |
Label1->Caption = "Data Size: " + IntToStr(AMMFile->DataSize);
|
71 |
}
|
72 |
//---------------------------------------------------------------------------
|
73 |
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
|
74 |
{
|
75 |
delete AMMFile;
|
76 |
AMMFile = NULL;
|
77 |
}
|
78 |
//--------------------------------------------------------------------------- |