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)
//===================================================================
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 )
// 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).
// 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)
//===================================================================
$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
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)
//===================================================================
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)
//===================================================================