Recent

Author Topic: [solved] rewrite(f) in a dll  (Read 1299 times)

Janfi

  • New member
  • *
  • Posts: 9
[solved] rewrite(f) in a dll
« on: June 05, 2019, 08:04:16 pm »
Hello there,

I was a turbo Pascal programmer from V3 to BP7 and I just discovered Lazarus few weeks ago. I love it., before I moved to Perl and a bit of Python.
For a project I have to write a windows 32 bits dll.
Until now, everything ok

but today, I had add some code in my dll :
  filemode :=  fmOpenReadWrite + fmShareDenyNone;
  assignFile(f,'toto.txt');
  rewrite (f);
 {
  w := 1;
  repeat
    Write(f, s2^[w]);
    inc(w);
  until s2^[w] = #$0000;
   }
  closefile(f);             

and it hangs, it is the Rewrite function that hangs, I tried to assign to c:\toto.txt but it's the same.

Do you know why please ?

Thanks

Janfi
« Last Edit: June 05, 2019, 10:21:56 pm by Janfi »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12845
  • FPC developer.
Re: rewrite(f) in a dll
« Reply #1 on: June 05, 2019, 08:25:27 pm »
In most current windows versions, you are not allowed to write to the system drive root directory.

Try with a different complete path without it being a limited location like the root or program files.

Janfi

  • New member
  • *
  • Posts: 9
Re: rewrite(f) in a dll
« Reply #2 on: June 05, 2019, 09:07:30 pm »
I tried, but no change.

  assignFile(f,'C:\Users\Léon\AppData\Roaming\MetaQuotes\Terminal\76AE827A66F7801B9D79B1FD1D2103FD\tester\files\toto.txt');
  {$i-}
  rewrite (f);
  {$i+}
  if IOResult > 0 then exit;   

The problem is that, from a dll i cannot display the errors and so I don't know how to see what's wrong...

Janfi

  • New member
  • *
  • Posts: 9
Re: rewrite(f) in a dll
« Reply #3 on: June 05, 2019, 09:26:45 pm »
The software for I'm writing a dll has an embeded c++ compiler (limited, i can't write a dll with). From that compiler I can write to the specified folder, so I suppose that a dll called by this application should also have the rights on the folder.

Except rights problem I have no idea.

Does a dll has limitations under windows 32 bits ?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12845
  • FPC developer.
Re: rewrite(f) in a dll
« Reply #4 on: June 05, 2019, 10:05:04 pm »
I tried, but no change.

  assignFile(f,'C:\Users\Léon\AppData\Roaming\MetaQuotes\Terminal\76AE827A66F7801B9D79B1FD1D2103FD\tester\files\toto.txt');
  {$i-}
  rewrite (f);
  {$i+}
  if IOResult > 0 then exit;   

The problem is that, from a dll i cannot display the errors and so I don't know how to see what's wrong...

The accent on leon, and thus codepages issues, probably. Or maybe appdata is still a special folder. Try to simply make a folder.

Keep it as simple as possible. Just new folder and name it "1" or so (without the quotes) and then write to c:\1\2.txt

Janfi

  • New member
  • *
  • Posts: 9
Re: rewrite(f) in a dll
« Reply #5 on: June 05, 2019, 10:21:32 pm »
Thank you very much Marcov, it works, with rewrite and FileCreate.

Next time I'll create a user, I will be carefull with accents.

I am confused for a so stupid error.

Janfi

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12845
  • FPC developer.
Re: [solved] rewrite(f) in a dll
« Reply #6 on: June 06, 2019, 11:01:07 am »
Note accents might be possible, but require something extra to initialize the RTL in the dll adequately.


 

TinyPortal © 2005-2018