Re: Help

new topic     » goto parent     » topic index » view thread      » older message » newer message
gwalters said...

I can't seem to find a way to quietly (without a black box) delete a file. I'm using EU 2.4 in windiows 7. Help would be appreciated.

Firstly, sorry you have to use an ancient version of Euphoria smile

Try something like this (p.s. I can't remember which libraries you have to include but I'm sure you'll work that out.)

function delete_file( sequence pFilePath) 
atom lLib 
atom lFunc 
atom lMem 
atom lRet 
 
lLib = open_dll("kernel32.dll") 
if lLib < 0 then 
    return -1 -- failed to open library 
end if 
 
lFunc = define_c_func(lLib, "DeleteFileA", {C_POINTER}, C_INT) 
if lFunc < 0 then 
    return -2 -- failed to define function 
end if 
 
lMem = allocate( length(pFilePath) + 1) 
if lMem = 0 then 
    return -3 -- failed to allocate RAM 
end if 
 
poke(lMem, pFilePath) 
poke(lMem + length(pFilePath), 0) 
 
lRet = c_func(lFunc, {lMem}) 
 
free(lMem) 
 
return (lRet != 0) -- 0 means failed, 1 means deleted 
 
end function 

(ed. Fixed c_func() call syntax. - It seems to work!)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu