Re: Deleting files in Win32?

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

On Fri, 7 Jan 2000 16:43:39 -0200, MiCkeY wrote:

>How can I delete/move a file in Win32 mode without display the DOS Window?

If you are using Win32Lib then you can include these functions:

-- start of tested file routines --
include win32lib.ew

constant
  xDeleteFile  = linkFunc(kernel32, "DeleteFileA", {C_POINTER}, C_INT),
  xMoveFile    = linkFunc(kernel32, "MoveFileA", {C_POINTER, C_POINTER},
C_INT)

--------------------------------------------------------------

global procedure deleteFile( sequence fName )
  atom file

  file = allocate_string( fName )
  if not c_func( xDeleteFile, {file} ) then
    warnErr( "xDeleteFile failed in procedure 'deleteFile'" )
  end if
  free( file )
end procedure

--------------------------------------------------------------

global procedure moveFile( sequence existingName, sequence newName )
  atom file1, file2

  file1 = allocate_string( existingName )
  file2 = allocate_string( newName )
  if not c_func( xMoveFile, {file1, file2} ) then
    warnErr( "xMoveFile failed in procedure 'moveFile'" )
  end if
  free( file1 )
  free( file2 )
end procedure
--------------------------------------------------------------

NOTES: the procedure 'moveFile' also works for simply renaming files.  You
may need to do some more error checking as your application sees fit.

If you need more file functions wrapped up (like CreateDirectory, CopyFile,
etc.) just let me know.  Maybe I'll code up a Win32Lib auxiliary
library...

-- Brian

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

Search



Quick Links

User menu

Not signed in.

Misc Menu