Recent

Author Topic: [solved by compromise] Cannot change directory permanently with ChDir()  (Read 10451 times)

Hartmut

  • Hero Member
  • *****
  • Posts: 749
Re: Cannot change directory permanently with ChDir()
« Reply #30 on: November 28, 2015, 04:58:43 pm »
Hello GetMem,

your demo works. But you used go32v2. I do not know that. My real program is big, uses a lot of FPC functions like dynamic arrays and so on. Can I compile every "normal" FPC console program with go32v2? Does the result run under Win7 32 and 64 bit?

Hello wp,

maybe you have Win7 64 bit? 16 bit TP programs can run under Win7 32 bit, but not under 64 bit.
I am happy that you could confirm my observation.
I am not talking about a "bug" in FPC. Only I have a problem where I try to find a solution under FPC.

Hello Bart, marcov and wp,

if your idea, that 16-bit programs from TP and 32 bit programs from FPC are handled differently by Win7, if this would be the explanation, than this would mean, that it is impossible to write a program like DOS-command "CD" as a 32 bit program? I have difficulties to believe this...
« Last Edit: November 28, 2015, 05:00:29 pm by Hartmut »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: Cannot change directory permanently with ChDir()
« Reply #31 on: November 28, 2015, 05:10:52 pm »
if your idea, that 16-bit programs from TP and 32 bit programs from FPC

32-bit *windows* programs.  I don't know about go32v2 and 16-bit msdos programs, but as getmem says they work fine, also when compiled with FPC.

So the difference is not 16 or 32-bit or 64-bit, but simply is it a *dos* or a *windows* program.

Quote
are handled differently by Win7, if this would be the explanation, than this would mean, that it is impossible to write a program like DOS-command "CD" as a 32 bit program? I have difficulties to believe this...

The "CD" command is internal in the shell under dos, windows and *nix. Probably exactly for these reasons.

Anyway you might give 4NT/take command shell (related to 4dos) a try. There is a lot more ball functionality in there that you might be able to use/abuse for your purposes.

Hartmut

  • Hero Member
  • *****
  • Posts: 749
Re: Cannot change directory permanently with ChDir()
« Reply #32 on: November 29, 2015, 06:45:24 pm »
I learned that a *windows*-program cannot change on exit the current directory of its calling DOS-window (a real *DOS*-program can).

So I decided to make a compromise to bypass my problem:
 - my program is now called by a batchfile
 - my program creates a 2nd batchfile with the "CD" command
 - the 1st batchfile calls the 2nd batchfile after my program exits
(this idea is near a suggestion from wp)

Thanks a lot to everybody who helped me with informations.

 

TinyPortal © 2005-2018