Solved

about IniFile.WriteBinaryStream?

Posted on 2003-11-01
2
953 Views
Last Modified: 2012-06-21
hi,experts
  why my code can not work!

function TResClass.AddToIni(IniFileName: string): boolean;
var
  IniFile: TIniFile;
  FileStream: TFileStream;
begin
  try
    try
      IniFile := TIniFile.Create(IniFileName);
      FileStream := TFileStream.Create(IniFileName, fmopenread or
        fmShareExclusive);
      IniFile.WriteBinaryStream('IniSction', IniFileName, FileStream);
    except
      result := false;
      exit;
    end;
  finally
    IniFile.Free;
    IniFile := nil;
  end;
  result := true;
end;

//
0
Comment
Question by:jbas
2 Comments
 
LVL 5

Accepted Solution

by:
DeerBear earned 100 total points
ID: 9662563
Hi,

Because you're calling the same file and are opening the
file stream in exclusive mode.
But the file is already in use from the Ini class, so... you
can't have it!

HTH,

Andrew
0
 

Author Comment

by:jbas
ID: 9662633
DeerBear,thanks
i use this,it can work,      
FileStream := TFileStream.Create(IniFileName, fmopenread or
        fmShareDenyNone);

i call this
button.click:
AddToIni('d:\1.bmp');
when i first call this founction,this can only write "[IniSction]
kk",when i second call this founction,it can write some data,eg:
[IniSction]
kk=5B6D797365635D0D0A6B6B3D0D0A

but how i get the source,
function TResClass.GetResFile(IniFileName: string): boolean;
var
  IniFile: TIniFile;
  IniSction: string;
  FileMemStream: TMemoryStream;
begin
  try
    try
      IniFile := TIniFile.Create(IniFileName);
      FileMemStream := TMemoryStream.Create;
      IniFile.ReadBinaryStream('mysec', 'kk', FileMemStream);
      FileMemStream.SaveToFile('d:\gogo.bmp');
    except
      result := false;
      exit;
    end;
  finally
    IniFile.Free;
    IniFile := nil;
    FileMemStream.Free;
  end;
  result := true;
end;

it can not get the bmp,and the ini file limit 64k?

thanks!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 105
Mobile Keyboard covers the display of the TMemo 3 88
how to resize animated Gif image in delphi ? 1 31
CheckListBox usage 3 59
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question