Re: Noob, learning how to use dll's.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Archarios wrote:
> 
> Still stuck, nothing is reporting anything close to what I really have.  Gotta
> go for now, I'll leave you with my code at the moment.
> }}}
<eucode>
> without warning
> include file.e
> include dll.e
> include safe.e
> 
> atom file1,DLL,GMSx,mem,result
> object temp
> file1 = open("D:\\obscured\\test.txt","w")
> 
> DLL = open_dll("kernel32.dll")
> GMSx = define_c_func(DLL,"GlobalMemoryStatusEx",{C_POINTER},C_INT)
> mem = allocate(512)
> result = c_func(GMSx,{mem})
> for count = mem+8 by 8 do
> printf(file1,"%d\n",float64_to_atom(peek({count,8})))
> end for
> puts(file1,peek({mem,512}))
> free(mem)
> close(file1)
> abort(0)
> </eucode>
{{{


There are a number of problems here.
safe.e can not be included this way as it will cause name space errors. As
documented you must rename safe.e to machine.e and include machine.e. You would
also have to rename the original machine.e before doing this. safe.e is intended
for debugging only, not general use.

The size of the structure need not be larger than 64 bytes. You must also poke
this value into the first entry.

The structure entries are 64 bit integers, not floating point numbers.
float64_to_atom() can not be used here.

This revised program should work:

without warning
include file.e
include dll.e
include machine.e

atom file1,DLL,GMSx,mem,result
object temp
file1 = open("D:\\obscured\\test.txt","w")

DLL = open_dll("kernel32.dll")
GMSx = define_c_func(DLL,"GlobalMemoryStatusEx",{C_POINTER},C_INT)
mem = allocate(64)
poke4(mem,64)
result = c_func(GMSx,{mem})
for count = mem+8 to mem+48 by 8 do
	printf(file1,"%d\n",peek4u(count)+peek4u(count+4)*#100000000)
end for
free(mem)
close(file1)
abort(0)


Larry Miller

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu