?
Solved

about IniFile.WriteBinaryStream?

Posted on 2003-11-01
2
Medium Priority
?
980 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
DeerBear earned 300 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 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