request for help

Frank Heckenbach frank at g-n-u.de
Fri Aug 31 23:24:37 CEST 2001


Prof. A Olowofoyeku (The African Chief) wrote:

> On 29 Aug 2001, at 3:38, Frank Heckenbach wrote:
> 
> > Prof. A Olowofoyeku (The African Chief) wrote:
> > 
> > > On 28 Aug 2001, at 15:06, Kocherlakota Harikrishna wrote:
> > > 
> > > > Hello,
> > > > I want equivalents for the following .Could any one  help me out : --
> > > > swap --get/freeenvironmentstrings --exitproc, exitcode --constants
> > > > like "fmclosed", "fmoutput" etc..
> > > 
> > > Some of them are in the dos and system units, and some of them don't
> > > exist anywhere. The get/freeenvironmentstrings stuff is purely a Windows
> > > API thing, so don't expect to find them in a standard GPC distribution. 
> > 
> > What do they do? Perhaps we can easily emulate them.
> 
> They are easy to emulate. The problem with emulating them in a standard 
> unit will be in those of us who use the WinAPI in Windows programs would 
> then have linker problems (until GPC gets qualified identifiers). So 
> perhaps a new "Delphi compat" unit should be created if you want to 
> emulate these things.
> 
> "GetEnvironmentStrings" returns a pointer (pChar in Delphi) to an 
> environment block for the current process. This is basically a list of 
> all the environment variables (each separated by a #0 and the whole list 
> is terminated by a #0#0). "FreeEnvironmentStrings" frees the memory 
> allocated for the block returned by "GetEnvironmentStrings".
> 
> The declarations are thus;
> Function GetEnvironmentStrings : pChar;
> Function FreeEnvironmentStrings (EnvBlock : pChar) : Boolean; { returns 
> true if the function succeeds }
> 
> How do you use the pointer returned by GetEnvironmentStrings? You walk 
> through it (i.e., jumping from one #0 to the next, etc) until you find 
> the variable that you want. It is ugly - but like I said, it is pretty 
> easy to emulate. Now, why someone would want to use this ugly M$ stuff 
> instead of the more sensible ones in the Dos unit beats me.

Me too. Internally, GPC stores its environment differently (schema
array of CStrings), but it wouldn't be too hard to write a function
that creates such a structure on demand. Should I do that (in the
System unit)?

Frank

-- 
Frank Heckenbach, frank at g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html




More information about the Gpc mailing list