Estoy buscando documentacion sobre la funcion SHFile() y no encuentro mas que un ejemplo incompleto ¿Me puede alguien decir la sintaxis de la funcion? Quiero borrar un fichero y que lo envie a la papelera sin pedir confirmacion.
Gracias.
static extern int SHFileOperation(ref SHFILEOPSTRUCT FileOp);
const int FO_DELETE = 3;
const int FOF_ALLOWUNDO = 0x40;
const int FOF_NOCONFIRMATION = 0x10; //No prompt dialogs
SHFILEOPSTRUCT shf = new SHFILEOPSTRUCT();
shf.wFunc = FO_DELETE;
shf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION;
shf.pFrom = "Filename.Extension";
SHFileOperation(ref shf);
#include "FiveWin.ch"
#define FO_MOVE 0x0001
#define FO_COPY 0x0002
#define FO_DELETE 0x0003
#define FO_RENAME 0x0004
#define FOF_MULTIDESTFILES 0x0001
#define FOF_CONFIRMMOUSE 0x0002
#define FOF_SILENT 0x0004 // don't create progress/report
#define FOF_RENAMEONCOLLISION 0x0008
#define FOF_NOCONFIRMATION 0x0010 // Don't prompt the user.
#define FOF_WANTMAPPINGHANDLE 0x0020 // Fill in SHFILEOPSTRUCT.hNameMappings
// Must be freed using SHFreeNameMappings
#define FOF_ALLOWUNDO 0x0040
#define FOF_FILESONLY 0x0080 // on *.*, do only files
#define FOF_SIMPLEPROGRESS 0x0100 // means don't show names of files
#define FOF_NOCONFIRMMKDIR 0x0200 // don't confirm making any needed dirs
#define FOF_NOERRORUI 0x0400 // don't put up error UI
#define FOF_NOCOPYSECURITYATTRIBS 0x0800 // dont copy NT file Security Attributes
#define FOF_NORECURSION 0x1000 // don't recurse into directories.
static oDlg
//----------------------------------------------------------------------------//
function Main()
DEFINE DIALOG oDlg TITLE "System Files management Dialogs"
@ 0.5, 1 BUTTON "&Copy" ACTION CopyFile( "dlgfile.exe", "c:\dlgfile.exe" ) ;
SIZE 30, 12
@ 1.5, 1 BUTTON "&Delete" ACTION DeleteFile( "c:\dlgfile.exe" ) ;
SIZE 30, 12
@ 2.5, 1 BUTTON "&Move" ACTION MoveFile( "dlgfile.exe", "c:\dlgfile.exe" ) ;
SIZE 30, 12
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------//
function CopyFile( cSource, cDestination )
return SHFile( oDlg:hWnd, FO_COPY, cSource + Chr( 0 ), cDestination )
//----------------------------------------------------------------------------//
function DeleteFile( cFileName )
return SHFile( oDlg:hWnd, FO_DELETE, cFileName + Chr( 0 ) )
//----------------------------------------------------------------------------//
function MoveFile( cSource, cDestination )
return SHFile( oDlg:hWnd, FO_MOVE, cSource + Chr( 0 ), cDestination )
//----------------------------------------------------------------------------/
SHFile( GetActiveWindow(), FO_DELETE, cFich + Chr( 0 ) , nAnd( FOF_ALLOWUNDO, FOF_NOCONFIRMATION ))
#include "FiveWin.ch"
#include "Fileio.ch"
#include "struct.ch"
#define FO_MOVE 0x0001
#define FO_COPY 0x0002
#define FO_DELETE 0x0003
#define FO_RENAME 0x0004
#define FOF_MULTIDESTFILES 0x0001
#define FOF_CONFIRMMOUSE 0x0002
#define FOF_SILENT 0x0004
#define FOF_RENAMEONCOLLISION 0x0008
#define FOF_NOCONFIRMATION 0x0010
#define FOF_WANTMAPPINGHANDLE 0x0020
#define FOF_ALLOWUNDO 0x0040
#define FOF_FILESONLY 0x0080
#define FOF_SIMPLEPROGRESS 0x0100
#define FOF_NOCONFIRMMKDIR 0x0200
#define FOF_NOERRORUI 0x0400
#define FOF_NOCOPYSECURITYATTRIBS 0x0800
#define FOF_NORECURSION 0x1000
function APapelera(cFich)
local oShFileOps
local nError
STRUCT oShFileOps
MEMBER hwnd AS LONG
MEMBER wFunc AS LONG
MEMBER pFrom AS STRING
MEMBER pTo AS STRING
MEMBER fFlags AS _INT
MEMBER fAnyOperationsAborted AS LONG
MEMBER hNameMappings AS LONG
MEMBER lpszProgressTitle AS STRING
ENDSTRUCT
oShFileOps:wFunc = FO_DELETE
oShFileOps:pFrom = cFich
oShFileOps:fFlags = nAnd( FOF_ALLOWUNDO, FOF_NOCONFIRMATION )
nError := ShFileOper(@oShFileOps)
return nError
DLL32 FUNCTION SHFileOper;
( @lpFileOp AS LPSTR ) ; // SHFILEOPSTRUCT
AS LONG PASCAL;
FROM "SHFileOperationA" LIB "SHELL32
Application
===========
Path and name: D:\CHOCO\CHoCo.Exe (32 bits)
Size: 523,264 bytes
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 12/08/2008, 11:23:13
Error description: Error BASE/1106 Argument error: REPLICATE
Args:
[ 1] = C
[ 2] = U
Stack Calls
===========
Called from: => REPLICATE(0)
Called from: TStruct.PRG => TSTRUCT:ADDMEMBER(0)
Called from: UTILS.PRG => APAPELERA(173)
Called from: CHOCO.PRG => MAIN(127)
System.......................
Antonio Linares wrote:Jose Luis,
Estas usando FWH 32 bits ?
Lo más sencillo es crear la función en C directamente, pero necesitas usar FWH.
SHFile( GetActiveWindow(), FO_DELETE, cFich + Chr( 0 ) , nAnd( FOF_ALLOWUNDO, FOF_NOCONFIRMATION )
#include "FiveWin.ch"
#define FO_DELETE 3
#define FOF_ALLOWUNDO 0x40
#define FOF_NOCONFIRMATION 0x10
function Main()
local nResultado := ShFile( GetActiveWindow(), FO_DELETE, "test.map" + Chr( 0 ), nil,;
nOr( FOF_ALLOWUNDO, FOF_NOCONFIRMATION ) )
MsgInfo( nResultado )
return nil
#pragma BEGINDUMP
#include <hbapi.h>
#include <Windows.h>
#include <ShellApi.h>
#include <ShlObj.h>
HB_FUNC( SHFILE )
{
SHFILEOPSTRUCT sh;
memset( ( char * ) &sh, 0, sizeof( sh ) );
sh.hwnd = ( HWND ) hb_parnl( 1 );
sh.wFunc = ( UINT ) hb_parnl( 2 );
sh.pFrom = ( LPSTR ) hb_parc( 3 );
sh.pTo = ( LPSTR ) hb_parc( 4 );
sh.fFlags = ( FILEOP_FLAGS ) hb_parnl( 5 );
hb_retnl( SHFileOperation( &sh ) );
}
#pragma ENDDUMP
Borland C++ 5.5 for Win32 Copyright (c) 1993, 2000 Borland
d:\pruebas\shfile\shfile.c:
Error E2209 C:\bcc55\include\exdisp.h 239: Unable to open include file 'ocidl.h'
Error E2209 C:\bcc55\include\docobj.h 86: Unable to open include file 'ocidl.h'
Error E2303 C:\bcc55\include\exdisp.h 2135: Type name expected
Error E2303 C:\bcc55\include\exdisp.h 2490: Type name expected
Error E2209 C:\bcc55\include\shldisp.h 284: Unable to open include file 'ocidl.h'
*** 5 errors in Compile **
Antonio Linares wrote:Aqui está funcionando bien y lo envia a la papelera.
Si quieres te envio el EXE para que lo pruebes
Return to FiveWin para CA-Clipper
Users browsing this forum: No registered users and 7 guests