Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Matt Groening on October 10, 2008, 02:04:57 PM

Title: Environment variables
Post by: Matt Groening on October 10, 2008, 02:04:57 PM
Hello.
I want create folders and files in Application Data.
I want use environment variables (%APPDATA%) for it.
How I can make it?
Title: Re: Environment variables
Post by: Mnemonic on October 15, 2008, 11:08:18 AM
There's no native support. You could get an environment variable by calling Windows API function using the "extern" function in WME script.
Title: Re: Environment variables
Post by: SoundGuy on June 10, 2009, 03:05:55 PM
Mnemonic - can you give an example for how to write the proper extern call to get an environment variable ?

Title: Re: Environment variables
Post by: HelLRaiseR on June 15, 2009, 05:43:38 PM

There is an exampleof the use. This case is for get a cnvironment variable.

Code: [Select]
// declaration
external "kernel32.dll" long GetEnvironmentVariable(string lpName , string lpBuffer , long nSize) ;

// use

var variable_name = "MY_VAR";
var variable_value = new String(255); // This var is passed by reference, the value of the environment variable is stored here
var value_lenght = 255;

GetEnvironmentVariable (variable_name, variable_value, value_length);