powerbuilder 如何给文件夹重命名
如何用pb把文件夹重新命名,没有响应的函数,如果用API的话,改用那个,谢谢!
[解决办法]
api比较麻烦,上传上来
forward
global type w_main from window
end type
type cb_2 from commandbutton within w_main
end type
type cb_1 from commandbutton within w_main
end type
type shfileopstruct from structure within w_main
end type
end forward
type shfileopstruct from structure
longhwnd
longwfunc
stringpfrom
stringpto
longfflags
longfanyoperationsaborted
longhnamemappings
stringlpszprogresstitle
end type
global type w_main from window
integer width = 1865
integer height = 700
boolean titlebar = true
string title = "Untitled"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cb_2 cb_2
cb_1 cb_1
end type
global w_main w_main
type prototypes
FUNCTION ulong SHFileOperation(ref SHFILEOPSTRUCT lpFileOp) LIBRARY &
"shell32.dll" ALIAS FOR "SHFileOperation;Ansi"
end prototypes
type variables
Private long FO_MOVE = 1//移动
Private long FO_COPY = 2//复制
Private long FO_DELETE = 3//删除
Private long FO_RENAME = 4//改名
Private long FOF_NOCONFIRMATION = 16//没有提示
Private long FOF_SILENT = 4//
Private long FOF_NOERRORUI = 4 * 16 * 16
end variables
forward prototypes
public function long wf_pathoperate (string frompath, string topath, long sorder)
end prototypes
public function long wf_pathoperate (string frompath, string topath, long sorder);SHFILEOPSTRUCT lstr_data
lstr_data.hwnd = 0
lstr_data.wfunc = sOrder
lstr_data.pFrom = FromPath
lstr_data.pTo = ToPath
lstr_data.fFlags = FOF_NOCONFIRMATION + FOF_SILENT + FOF_NOERRORUI
return SHFileOperation(lstr_data)
//PathOperate "c:\a", "c:\e", FO_RENAME
end function
on w_main.create
this.cb_2=create cb_2
this.cb_1=create cb_1
this.Control[]={this.cb_2,&
this.cb_1}
end on
on w_main.destroy
destroy(this.cb_2)
destroy(this.cb_1)
end on
event open;
/* //结构说明
Private Type SHFILEOPSTRUCT
hwnd As Long //句柄
wFunc As Long //操作命令
pFrom As String //源文件夹
pTo As String //目标文件夹
fFlags As Integer //
fAnyOperationsAborted As Long //不详
hNameMappings As Long //不详
lpszProgressTitle As String //当取 FOF_SIMPLEPROGRESS 时,此参数才被使用
End Type
*/
end event
type cb_2 from commandbutton within w_main
integer x = 942
integer y = 196
integer width = 658
integer height = 132
integer taborder = 20
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "命令 修改目录"
end type
event clicked;
//修改c:\a 修改为c:\e
Run("rename c:\a e")
end event
type cb_1 from commandbutton within w_main
integer x = 242
integer y = 196
integer width = 658
integer height = 132
integer taborder = 10
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "API 修改目录"
end type
event clicked;Wf_PathOperate("c:\a", "c:\e", FO_RENAME)
end event