Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening textfiles in a DLL

Status
Not open for further replies.

mattlacey

Programmer
Oct 11, 2001
22
0
0
GB
I am writing a DLL in Delphi 5 that needs to open text files and then perform analysis on the contents of the file. This is all fine when i write it in a standard EXE but when i try and run the code in a DLL I get a EInOutError exception.

My code looks like this:
Code:
function bIsDestinationAvailable(i_sPath, i_sPcode: String): Boolean; stdcall;
var
  F1: TextFile;
  sPcodeDat: String;
begin
  AssignFile(F1, i_sPath) ;
  Reset(F1) ;    //This line causing an I/O error
  Read(F1, sPcodeDat) ;
  CloseFile(F1) ;
  ....
end;

Any help, suggestions, pointers, etc. would be gratefully received.

Matt.
 
If you handle with strings in DLLs use the sharemem unit in both, the DLL and the program (project.dpr).
Be shure, sharemem is the first unit in the uses clause.

Look at my reply to: 'DLL and TStringList' a page before.

DLLs works with PChars, may be thats the problem.
 
Yeah, I saw your post and checked my inclusion of ShareMem. I also have functions in the same DLL that successfully pass and return strings, so it can't be a String/PChar issue. ShareMem & the borlndmm.dll enable the use of strings in DLLs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top