1. please verify

--------------1AB37F2152E

Please verify the code below and please execute it to see which errors
are in it :

--------------1AB37F2152E
Content-Disposition: inline; filename="prova.exw"

include machine.e
include dll.e
atom kernel, SetEnvironmentVariable
kernel = open_dll("kernel32.dll")
SetEnvironmentVariable = define_c_func(kernel, "SetEnvironmentVariableA",
{C_POINTER, C_POINTER},C_INT)
? c_func(SetEnvironmentVariable,
{allocate_string("ciao"),allocate_string("oiac")})

--------------1AB37F2152E--

new topic     » topic index » view message » categorize

2. Re: please verify

Hello,

Flaminio wrote:

>Please verify the code below and please execute it to see which errors
>are in it :
>include machine.e
>include dll.e
>atom kernel, SetEnvironmentVariable
>kernel = open_dll("kernel32.dll")
>SetEnvironmentVariable = define_c_func(kernel, "SetEnvironmentVariableA",
>{C_POINTER, C_POINTER},C_INT)
>? c_func(SetEnvironmentVariable,

I'm not sure what this code does but it doesn't give me any errors.
It displays "1" ...
for a fraction of a second. Only my quick eyes could catch it...
with the help of the following code at the end of course:

--------------------------
include get.e
if wait_key () then end if
--------------------------

Is this what it's supposed to do?

later,
Lewis Townsend

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: please verify

On Wed, 13 Oct 1999 21:59:50 +0100, Flaminio <newpow at TIN.IT> wrote:

>Please verify the code below and please execute it to see which errors
>are in it :
>
>include machine.e
>include dll.e
>atom kernel, SetEnvironmentVariable
>kernel = open_dll("kernel32.dll")
>SetEnvironmentVariable = define_c_func(kernel, "SetEnvironmentVariableA",
{C_POINTER, C_POINTER},C_INT)
>? c_func(SetEnvironmentVariable, {allocate_string("ciao"),allocate_string
("oiac")})
>

Flaminio,

There is nothing wrong with the code above but keep in mind that the
SetEnvironmentVariable function sets the value of an environment variable
for the current process.  You will have to use the GetEnvironmentVariable
function to retrieve the value.  Below I give an example with output:

include get.e
include machine.e
include dll.e
atom kernel, SetEnvironmentVar, GetEnvironmentVar, buffer, i
kernel = open_dll("kernel32.dll")
buffer = allocate(50)

SetEnvironmentVar = define_c_func(kernel, "SetEnvironmentVariableA",
{C_POINTER, C_POINTER}, C_INT)

GetEnvironmentVar = define_c_func(kernel, "GetEnvironmentVariableA",
{C_POINTER, C_POINTER, C_INT}, C_INT)

? c_func(SetEnvironmentVar, {allocate_string("bkb"),allocate_string
("brian")})

? c_func(GetEnvironmentVar, {allocate_string("bkb"), buffer, 50})

i = wait_key()

The above snippet produces:
1
5

The '1' means that SetEnvironmentVar was successful.  The '5' means that
environment variable 'bkb' holds a string of length '5' (the length
of 'brian').  I would have to peek at the location 'buffer' to read that
environment variable.  (A bit of a hassle...)

Is there a reason you need an environment variable for your process?
Couldn't you just use a global variable or something?

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu