如何在pb6.5中显示指定盘下(比如c:\)下的所有文件夹.

yhwycg 2002-11-04 02:55:08
如何在pb6.5中显示指定盘下(比如c:\)下的所有文件夹.
...全文
85 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hzhxxx 2002-12-09
  • 打赏
  • 举报
回复
end function

public function string of_browseforanything (long alhparent, string asprompt);//===================================================================
// Function: nvo_shell32::of_BrowseForAnything()
//-------------------------------------------------------------------
// Description:Macro function to call of_SHBrowseForFolder with correct
// BIF_xxx constant
//-------------------------------------------------------------------
// Parameters: alhParent (LONG)
// asPrompt (STRING)
//
// alhParent
// Handle of the owner window for the dialog box.
// asPrompt
// Text to go in the banner over the tree.
//-------------------------------------------------------------------
// Returns: Returns the selected printer/computer/folder name.
//-------------------------------------------------------------------
// Author: RC Sizer (Mar 1999)
//===================================================================

RETURN This.of_SHBrowseForFolder( alhParent, asPrompt, BIF_BROWSEINCLUDEFILES )

end function

private function boolean of_shfileoperation (ref shfileopstruct lpfileop);//===================================================================
// Function: nvo_shell32::of_SHFileOperation()
//-------------------------------------------------------------------
// Description:Performs a copy, move, rename, or delete operation on
// a file system object.
//
// NOTE: This is a PRIVATE function. Use the of_FileOperationXXX()
// functions. They populate the structure before calling this
// shell function.
//-------------------------------------------------------------------
// Parameters: lpFileOp (shfileopstruct)
//
// lpFileOp
// Pointer to an SHFILEOPSTRUCT structure that contains information
// the function needs to carry out the operation.
//-------------------------------------------------------------------
// Returns: BOOLEAN - TRUE = Success
// FALSE = Failure
//-------------------------------------------------------------------
// Author: RC Sizer (Mar 1999)
//===================================================================

RETURN ( SHFileOperation(lpFileOp) = 0)

end function

private function long of_makechar (readonly string asstrings[], ref character acchar[]);//===================================================================
// Function: nvo_shell32::of_MakeChar()
//-------------------------------------------------------------------
// Description:Converts a string array into a single char array.
// Each of the elements in the string array are
// seperated with a null in the char array.
// The last element has a double-null terminator.
//
// NOTE: This is used by the FileOperationXXX functions to convert
// an array of filenames into a char array.
//
// NOTE: CharArray[] + Char(0) + CharArray[] has the same effect as
// CharArray[] + CharArray[] (a PB6 feature ?)
// So I step through the array character by character, which is slower.
//-------------------------------------------------------------------
// Parameters: asStrings (STRING ARRAY)
// acChar (ref CHAR ARRAY)
//
// asStrings
// Array of strings (usually filenames).
// acChar
// Returned char array containing all of the strings in the string
// array. Each string is seperated with a null character.
//
// Example: Given a string array of { '123', '456', '789' }, the
// char array will contain: 123<0>456<0>789<0><0>
// where <0> is the NULL char.
//-------------------------------------------------------------------
// Returns: (LONG) = Length of character array
//-------------------------------------------------------------------
// Author: RC Sizer (Mar 1999)
//===================================================================

char lcChar[], lcString[]
long llStringCount, llStringIndex
long llCharCount, llCharIndex

// Count number of strings in array
llStringCount = UpperBound( asStrings[] )

IF (llStringCount > 0) THEN
// Add each of the strings to the char array
FOR llStringIndex = 1 TO llStringCount

// Get length of current string
llCharCount = Len( asStrings[llStringIndex] )

IF llCharCount > 0 THEN

// Convert string into char array
lcString = asStrings[llStringIndex]

// Concatenate string to existing char array
FOR llCharIndex = 1 TO llCharCount
lcChar[UpperBound(lcChar) + 1] = lcString[llCharIndex]
NEXT

// Terminate each string with a null character
lcChar[UpperBound(lcChar) + 1] = Char(0)
END IF
NEXT
// The last element must be double-null terminated
lcChar[UpperBound(lcChar) + 1] = Char(0)
END IF

// Set reference argument
acChar = lcChar

// Return length of char array
RETURN UpperBound( lcChar )

end function
hzhxxx 2002-12-09
  • 打赏
  • 举报
回复

SHFILEOPSTRUCT lpFileOp
Char lcFrom[]
long lpString
boolean lbDelete = FALSE

// Convert array of strings into a single null-seperated char array
IF This.of_MakeChar( asFrom[], lcFrom ) > 0 THEN

// Allocate memory for char array (pString)
lpString = LocalAlloc( 0, UpperBound(lcFrom) )

// Copy char array into newly allocated memory
RtlMoveMemory( lpString, lcFrom, UpperBound(lcFrom) )

// Populate FileOperation structure
lpFileOp.hWnd = 0 // No parent dialog
lpFileOp.wFunc = FO_DELETE // Perform a DELETE operation
lpFileOp.pFrom = lpString // Source files
lpFileOp.pTo = "" // Not used for DELETE
lpFileOp.fFlags = FOF_ALLOWUNDO + FOF_FILESONLY // Save UNDO info
lpFileOp.fAnyOperationsAborted = FALSE // This is an OUTPUT var to indicate user aborted
lpFileOp.hNameMappings = 0 // Do not want old/new pathnames
lpFileOp.lpszProgressTitle = "" // Display default message (ie. file currently being copied).

// Perform delete
lbDelete = This.of_SHFileOperation( lpFileOp )

// Free allocated memory
LocalFree( lpString )
END IF

// Return results of delete
RETURN lbDelete

end function

public function string of_getspecialfolderlocation (readonly long alfolder);//===================================================================
// Function: nvo_shell32::of_GetSpecialFolderLocation()
//-------------------------------------------------------------------
// Description:Retrieves the location of a special folder.
//-------------------------------------------------------------------
// Parameters: alFolder (LONG)
//
// alFolder
// One of the following constants:
// CSIDL_BITBUCKET Recycle bin
// CSIDL_CONTROLS Control Panel
// CSIDL_DESKTOP Windows desktop
// CSIDL_DESKTOPDIRECTORY File system directory used to physically
// store file objects on the desktop
// (not to be confused with the desktop folder itself).
// CSIDL_DRIVES My Computer
// CSIDL_FONTS Virtual folder containing fonts.
// CSIDL_NETHOOD File system directory containing objects that appear in
// the network neighborhood.
// CSIDL_NETWORK Network Neighborhood
// CSIDL_PERSONAL File system directory that serves as a common
// respository for documents.
// CSIDL_PRINTERS Printers folder
// CSIDL_PROGRAMS File system directory that contains the user抯 program groups
// (which are also file system directories).
// CSIDL_RECENT File system directory that contains the user抯
// most recently used documents.
// CSIDL_SENDTO File system directory that contains Send To menu items.
// CSIDL_STARTMENU File system directory containing Start menu items.
// CSIDL_STARTUP File system directory that corresponds to the user抯
// Startup program group.
// CSIDL_TEMPLATES File system directory that serves as a common repository
// for document templates.
// CSIDL_COMMON_STARTMENU Start Menu common to all users
// CSIDL_COMMON_PROGRAMS Program Files common to all users
// CSIDL_COMMON_STARTUP Startup common to all users
// CSIDL_COMMON_DESKTOPDIRECTORY Common desktop
// CSIDL_APPDATA ???
// CSIDL_PRINTHOOD Printer neighborhood.
//-------------------------------------------------------------------
// Returns: <none>
//-------------------------------------------------------------------
// Author: RC Sizer (Mar 1999)
//===================================================================

long lpIDL
string lsPath

// NOTE: alFolder is NOT validated.

// Get IDList to special folder
SHGetSpecialFolderLocation( 0, alFolder, lpIDL )

IF (lpIDL > 0) THEN
// Allocate space before calling API function
lsPath = Space( MAX_PATH )

// Extract path name from IDList
IF NOT SHGetPathFromIDList( lpIDL, lsPath ) THEN
// Error extracting path
lsPath = ""
END IF
ELSE
// Invalid aiFolder argument
lsPath = ""
END IF

RETURN Trim(lsPath)

end function

public function boolean of_formatdrive (readonly character acdrive);//===================================================================
// Function: nvo_shell32::of_FormatDrive()
//-------------------------------------------------------------------
// Description:Opens the standard disk format window, and defaults
// to the specified drive.
//-------------------------------------------------------------------
// Parameters: acDrive (CHAR)
//
// acDrive
// Drive letter (e.g. A, B, C)
//-------------------------------------------------------------------
// Returns: BOOLEAN - TRUE = Success
// FALSE = FAILURE
//-------------------------------------------------------------------
// Author: RC Sizer (Mar 1999)
//===================================================================

RETURN (SHFormatDrive( 0, Asc(Upper(acDrive)) - 65, 0, 0 ) <> 0)
hzhxxx 2002-12-09
  • 打赏
  • 举报
回复
$PBExportHeader$nvo_shell32.sru
$PBExportComments$Shell32 API functions
forward
global type nvo_shell32 from nonvisualobject
end type
type browseinfo from structure within nvo_shell32
end type
type shfileopstruct from structure within nvo_shell32
end type
end forward

type browseinfo from structure
long hwndowner
long pidlroot
string pszdisplayname
string lpsztitle
unsignedlong ulflags
unsignedlong lpfn
unsignedlong lparam
long iimage
end type

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

global type nvo_shell32 from nonvisualobject autoinstantiate
end type

type prototypes
// Shell functions
Subroutine SHAddToRecentDocs( ulong uFlags, Ref String pV ) Library "shell32.dll"
Function long SHBrowseForFolder( Ref BROWSEINFO lpBi ) Library "shell32.dll"
Function boolean SHGetPathFromIDList( long pIDL, Ref String pszPath ) Library "shell32.dll" Alias For "SHGetPathFromIDListA"
Function long SHFileOperation( Ref SHFILEOPSTRUCT lpFileOp ) Library "shell32.dll" Alias For "SHFileOperationA"
Function long SHGetSpecialFolderLocation( long hwndOwner, long nFolder, Ref Long ppidl ) Library "shell32.dll"
Function long SHFormatDrive( ulong hWnd, ulong iDrive, ulong iCapacity, ulong iType ) Library "shell32.dll"

// Memory functions
Function long RtlMoveMemory(REF Char Destination[], long Source, long Size) library "kernel32"
Function long RtlMoveMemory(long Destination, REF Char Source[], long Size) library "kernel32"
Function long LocalAlloc(long Flags, long Bytes) library "kernel32"
Function long LocalFree(long MemHandle) library "kernel32"

end prototypes

type variables
// MAX_PATH constant for file operations
Private constant long MAX_PATH = 260

// SHBrowseForFolder constants
Private:
constant ulong BIF_RETURNONLYFSDIRS = 1 // Browse for directory
constant ulong BIF_DONTGOBELOWDOMAIN = 2 // For starting the Find Computer
constant ulong BIF_STATUSTEXT = 4
constant ulong BIF_RETURNFSANCESTORS = 8
constant ulong BIF_EDITBOX = 16
constant ulong BIF_BROWSEFORCOMPUTER = 4096 // Browse for computer
constant ulong BIF_BROWSEFORPRINTER = 8192 // Browse for printers
constant ulong BIF_BROWSEINCLUDEFILES = 16384 // Browse for everything

// SHAddToRecentDocs constants
Private:
constant ulong SHARD_PIDL = 1
constant ulong SHARD_PATH = 2

// File Operation constants
Private:
constant ulong FO_MOVE = 1
constant ulong FO_COPY = 2
constant ulong FO_DELETE = 3
constant ulong FO_RENAME = 4

// File Operation flags
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

// SHGetSpecialFolderLocation constants
Public:
constant ulong CSIDL_DESKTOP = 0 // 0x0000
constant ulong CSIDL_PROGRAMS = 2 // 0x0002
constant ulong CSIDL_CONTROLS = 3 // 0x0003
constant ulong CSIDL_PRINTERS = 4 // 0x0004
constant ulong CSIDL_PERSONAL = 5 // 0x0005
constant ulong CSIDL_FAVORITES = 6 // 0x0006
constant ulong CSIDL_STARTUP = 7 // 0x0007
constant ulong CSIDL_RECENT = 8 // 0x0008
constant ulong CSIDL_SENDTO = 9 // 0x0009
constant ulong CSIDL_BITBUCKET = 10 // 0x000a
constant ulong CSIDL_STARTMENU = 11 // 0x000b
constant ulong CSIDL_DESKTOPDIRECTORY = 16 // 0x0010
constant ulong CSIDL_DRIVES = 17 // 0x0011
constant ulong CSIDL_NETWORK = 18 // 0x0012
constant ulong CSIDL_NETHOOD = 19 // 0x0013
constant ulong CSIDL_FONTS = 20 // 0x0014
constant ulong CSIDL_TEMPLATES = 21 // 0x0015
constant ulong CSIDL_COMMON_STARTMENU = 22 // 0x0016
constant ulong CSIDL_COMMON_PROGRAMS = 23 // 0X0017
constant ulong CSIDL_COMMON_STARTUP = 24 // 0x0018
constant ulong CSIDL_COMMON_DESKTOPDIRECTORY = 25 // 0x0019
constant ulong CSIDL_APPDATA = 26 // 0x001a
constant ulong CSIDL_PRINTHOOD = 27 // 0x001b

end variables

forward prototypes
public function string of_browseforprinter (long alhparent, string asprompt)
public function string of_browseforcomputer (long alhparent, string asprompt)
public function string of_browseforanything (long alhparent, string asprompt)
private function boolean of_shfileoperation (ref shfileopstruct lpfileop)
private function long of_makechar (readonly string asstrings[], ref character acchar[])
public function boolean of_fileoperationmove (readonly string asfrom[], readonly string asto)
public function boolean of_fileoperationdelete (readonly string asfrom[])
public function string of_getspecialfolderlocation (readonly long alfolder)
public function boolean of_formatdrive (readonly character acdrive)
public function string of_browseforfolder (long alhparent, string asprompt)
private function string of_shbrowseforfolder (long alhparent, string asprompt, long alflags)
public function boolean of_fileoperationcopy (readonly string asfrom[], readonly string asto)
public subroutine of_clearrecentdocs ()
public subroutine of_addtorecentdocs (string asfilename)
end prototypes

public function string of_browseforprinter (long alhparent, string asprompt);//===================================================================
// Function: nvo_shell32::of_BrowseForPrinter()
//-------------------------------------------------------------------
// Description:Macro function to call of_SHBrowseForFolder with correct
// BIF_xxx constant
//-------------------------------------------------------------------
// Parameters: alhParent (LONG)
// asPrompt (STRING)
//
// alhParent
// Handle of the owner window for the dialog box.
// asPrompt
// Text to go in the banner over the tree.
//-------------------------------------------------------------------
// Returns: Returns the selected printer name.
//-------------------------------------------------------------------
// Author: RC Sizer (Mar 1999)
//===================================================================

RETURN This.of_SHBrowseForFolder( alhParent, asPrompt, BIF_BROWSEFORPRINTER )

end function

public function string of_browseforcomputer (long alhparent, string asprompt);//===================================================================
// Function: nvo_shell32::of_BrowseForComputer()
//-------------------------------------------------------------------
// Description:Macro function to call of_SHBrowseForFolder with correct
// BIF_xxx constant
//-------------------------------------------------------------------
// Parameters: alhParent (LONG)
// asPrompt (STRING)
//
// alhParent
// Handle of the owner window for the dialog box.
// asPrompt
// Text to go in the banner over the tree.
//-------------------------------------------------------------------
// Returns: Returns the selected computer name.
//-------------------------------------------------------------------
// Author: RC Sizer (Mar 1999)
//===================================================================

RETURN This.of_SHBrowseForFolder( alhParent, asPrompt, BIF_BROWSEFORCOMPUTER )
dotnba 2002-12-06
  • 打赏
  • 举报
回复
不会
就会Day Day Up

-----------------------------------------
向前进,向前进,向着红星进,向着红星进
我的红星也有你的一半
-----------------------------------------

740

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 脚本语言
社区管理员
  • 脚本语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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