怎么获取光盘盘符?

gxbhhp 2002-07-29 03:52:38
1、怎么获取光盘盘符?
2、怎么给文件改名?
3、获取网络驱动器?
...全文
50 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhanwei 2002-07-29
  • 打赏
  • 举报
回复
1、
Get the CDROM drive letter
[Function declarations]
FUNCTION ulong GetLogicalDrives() LIBRARY "Kernel32.dll"
FUNCTION uint GetDriveType( Ref String as_root_path )
LIBRARY "kernel32.dll" ALIAS FOR "GetDriveTypeA"

[PB function String of_GetCDRootPath()]

integer li_ctr
string ls_root
ulong lul_drives, lul_rem

lul_drives = GetLogicalDrives()

DO
lul_rem = MOD(lul_drives, 2)
IF lul_rem = 1 THEN
ls_root = Char(li_ctr + 64) + ":\"
IF GetDriveType(ls_root_path) = 5 THEN
Return ls_root_path
END IF
li_ctr ++
END IF
lul_drives /= 2
LOOP UNTIL lul_drives = 0

RETURN ""

2、Rename a file
Simply "move" it under a new name with the function FUNCTION BOOLEAN MoveFileA(STRING oldfile, STRING newfile)
LIBRARY "Kernel32.dll"

3、Retrieve the UNC from a mapped drive
To convert a normal paths (N:\PATH) to UNC (\\SERVER\PATH). [local external function declaration]
FUNCTION ulong WNetGetConnectionA ( ref string drv, ref string unc, ref ulong buf ) &
LIBRARY "mpr.dll"

[powerscript]
string ls_tmp, ls_unc
Ulong ll_rc, ll_size

ls_tmp = upper(left(as_path,2))
IF right(ls_tmp,1) <> ":" THEN RETURN as_path

ll_size = 255
ls_unc = Space(ll_size)

ll_rc = WNetGetConnectionA (ls_tmp, ls_unc, ll_size)
IF ll_rc = 2250 THEN
// prbably local drive
RETURN as_path
END IF

IF ll_rc <> 0 THEN
MessageBox("UNC Error","Error " + string(ll_rc) + " retrieving UNC for " + ls_tmp)
RETURN as_path
END IF

// Concat and return full path
IF len(as_path) > 2 THEN
ls_unc = ls_unc + mid(as_path,3)
END IF

RETURN ls_unc

joss 2002-07-29
  • 打赏
  • 举报
回复
PB编程俱乐部有这文面的例子,比我们讲得详细!!
hjd_cw 2002-07-29
  • 打赏
  • 举报
回复
FUNCTION BOOLEAN MoveFileA(STRING oldfile, STRING newfile)
LIBRARY "Kernel32.dll"
hjd_cw 2002-07-29
  • 打赏
  • 举报
回复
定义外部函数
FUNCTION ulong GetLogicalDrives() LIBRARY "Kernel32.dll"
FUNCTION uint GetDriveType( Ref String as_root_path )
LIBRARY "kernel32.dll" ALIAS FOR "GetDriveTypeA"

[PB 函数 String of_GetCDRootPath()]

integer li_ctr
string ls_root
ulong lul_drives, lul_rem

lul_drives = GetLogicalDrives()

DO
lul_rem = MOD(lul_drives, 2)
IF lul_rem = 1 THEN
ls_root = Char(li_ctr + 64) + ":\"
IF GetDriveType(ls_root_path) = 5 THEN
Return ls_root_path
END IF
li_ctr ++
END IF
lul_drives /= 2
LOOP UNTIL lul_drives = 0

RETURN ""

1,079

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧