您现在的位置:动易网络>> 帮助文档>> PowerBuilder>>正文内容

pb删除非空文件夹的方法

问:

pb删除非空文件夹的方法

答:

以下内容是一个自定义userobject在Edit Source下的全部内容,新建一个命名为nvo_folder的自定义userobject,并保存,然后在Edit Source下用以下内容替换原内容即可。

forward
global type nvo_folder from nonvisualobject
end type
type shfileopstruct from structure within nvo_folder
end type
end forward

type shfileopstruct from structure
    long        hwnd
    unsignedlong        wfunc
    string        pfrom
    string        pto
    unsignedlong        fflags
    boolean        fanyoperationsaborted
    long        hnamemappings
    string        lpszprogresstitle
end type

global type nvo_folder from nonvisualobject autoinstantiate
end type

type prototypes
Function long SHFileOperation( Ref SHFILEOPSTRUCT lpFileOp ) Library "shell32.dll " Alias For "SHFileOperationA"

end prototypes
type variables
//   文件操作变量
Private:
constant   ulong   FO_MOVE =   1
constant   ulong   FO_COPY =   2
constant   ulong   FO_DELETE =   3
constant   ulong   FO_RENAME =   4

//   文件操作标志位
Private:
constant   ulong   FOF_MULTIDESTFILES =   1 //   0x0001
constant   ulong   FOF_CONFIRMMOUSE =   2 //   0x0002
constant   ulong   FOF_SILENT =   4 //   0x0004
constant   ulong   FOF_RENAMEONCOLLISION =   8 //   0x0008
constant   ulong   FOF_NOCONFIRMATION =   16 //   0x0010
constant   ulong   FOF_WANTMAPPINGHANDLE =   32 //   0x0020
constant   ulong   FOF_ALLOWUNDO =   64 //   0x0040
constant   ulong   FOF_FILESONLY =   128 //   0x0080
constant   ulong   FOF_SIMPLEPROGRESS =   256 //   0x0100
constant   ulong   FOF_NOCONFIRMMKDIR =   512 //   0x0200
constant   ulong   FOF_NOERRORUI =   1024 //   0x0400
end variables

forward prototypes
public function boolean of_removefolder (string as_folder)
end prototypes

public function boolean of_removefolder (string as_folder);//删除文件夹as_folder

SHFILEOPSTRUCT FileOp
FileOp.fFlags = FOF_NOCONFIRMATION
FileOp.hNameMappings = 0
FileOp.hwnd = 0
FileOp.lpszProgressTitle = ''
FileOp.pFrom = as_folder
FileOp.pTo = ''
FileOp.wFunc = FO_Delete
return SHFileOperation(FileOp) = 0


end function

on nvo_folder.create
call super::create
TriggerEvent( this, "constructor" )
end on

on nvo_folder.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

 

 


感动 同情 无聊 愤怒 搞笑 难过 高兴 路过
【字体: 】【收藏】【打印文章】【查看评论

相关文章

    没有相关内容