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.
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Author of Chief's Installer Pro for Win32 Email: African_Chief@bigfoot.com http://www.bigfoot.com/~african_chief/