Home > Enterprise >  How to call _putenv from Delphi?
How to call _putenv from Delphi?

Time:09-17

Is there a (simple) way to call _putenv() from my Delphi app?

This is a follow-up of SetEnvironmentVariable() does not seem to set values that can be retrieved by getenv().

CodePudding user response:

According to your earlier question, you Delphi EXE is loading a DLL written in C . So, check if your EXE process is getting the msvcrt##.dll or ucrtbase.dll runtime DLL loaded into it by the C DLL in question. If so, then the EXE can find the runtime DLL's HMODULE handle via GetModuleHandle(), and then retrieve a pointer to _putenv/_s() via GetProcAddress(), and then call it.

  • Related