VDF-GUIdance logo



  Visual DataFlex Logo
  

Shared knowledge leads to accumulated knowledge

        Printer Friendly Page


Size: 20 KB Download
Date Created: 10/31/1999
Date Updated: 09/05/2017
Author: Wil van Antwerpen
Company: Antwise Solutions
Summary:
With this package (vwin32fh.pkg) you can copy, move, delete or rename any file, select a folder, test if a folder exists, create a new folder, delete an existing folder, start a program by its registered name, test if a file exists and more... all in the windows-environment.

Windows Filehandling



The vWin32fh package is a wrapper for standard windows API calls used for file handling.
The download includes a small example program that shows you how-to use some of these functions.

The wrapperfunctions declared in this package all support long file and foldernames.
.

Supported methods



Function vSelect_File Global String sSupportedFileTypes String sCaptionText String sInitial_Folder Returns String
This function opens the Windows standard file open dialog and returns the selected file_name. Returns '' if the user didn't make a selection.

Procedure vDDE_Error_Handler Integer iErrorID (obsolete)
This method shows the error message for the passed DDE Error ID.
Please use the DDE_Error_To_String function instead

Function DDE_Error_To_String Integer iErrorID Returns String
This function returns error message for the passed DDE Error ID.

Function vFolderExists Global String sFolderName returns Integer
Does the directory exist? - No= 0, Yes= 1
This also works with UNC path encoding and wildcards

Function vSHBrowseForFolder Global String sDialogTitle returns String
returns folder name if a folder was selected, otherwise returns ""

Function vCreateDirectory Global String sNewFolder Returns Integer
returns:
  • 0 if the folder is created.
  • 1 if the API-call returned an error.

Function vRemoveDirectory Global String sFolder Returns Integer
With this function one can remove a directory.
returns:
  • 0 if the folder is removed.
  • 1 if the API-call returned an error (Use GetLastE
  • 2 if the folder did not exist
  • 3 if the sFolder parameter passed is equal to ""

Function vVerifyNewFolder Global String sFolderName Returns Integer
This function informs the user that he entered a yet unknown folder and asks if he/she wants to create the folder (Yes/No)
Choice: "Yes" - this creates the folder, if successful, the function returns false else it will be true.
Choice: "No" - returns TRUE, This allows the programmer to take action, for example: to stop a save
Precondition: A foldername must be entered. We do not check for empty paths
This function returns a non-zero value if the folder isn't created afterwards
Procedure vShellExecute global String sOperation String sDocument String sParameters String sPath
This will perform an operation on a file (e.g. open) with the application registered in the Windows Registry to open that type of file (via its extension) sOperation would be "OPEN" (it could also be "PRINT" etc).

Function vDeleteFile Global String sFileName Returns Integer
Uses WinAPI to delete the file with sFileName.
Returns a nonzero value if the operation failed.

Function vCopyFile Global String sSource String sDestination returns Integer
Uses WinAPI to copy the file sSource to the folder in sDestination.
Returns a nonzero value if the operation failed.

Function vMoveFile Global String sSource String sDestination returns Integer
Uses WinAPI to move the file sSource to the folder in sDestination.
Returns a nonzero value if the operation failed.

Function vRenameFile Global String sSource String sDestination returns Integer
Uses WinAPI to rename the file or folder sSource into sDestination.
Returns a nonzero value if the operation failed.

Function vGetWindowsDirectory Returns String
Returns the name of the folder where windows is installed.

Function vMakeTempFile Returns String
This function creates a temporary file. It will first try to create this in the normal temp-folder.
If that one doesn't exist the tempfile is created in the current folder.
The file is always prefixed with "tmp" and if succesful will return the name of the created file.
In the case of errors, an empty string is returned.

Function vCreateTempFileInPath String Path String Prefix Returns String

Function vConvertFileDateTime Global Dword dwLowDateTime Dword dwHighDateTime Returns String
This function can be used to convert WinAPI file datetimes into a string that returns the date/time in a readable fashion.
Function vFilePathExists String sFilePathMask Returns Integer
A windows replacement for the standard function FileExists.
This version will also return (true) for a file when it is open by an application.
Note that you can apply normal windows mask-signs in the filename such as * and ?
Example: Get vFilePathExists "C:\config.sy?"
This will return true if you have a file matching these conditions. (aka config.sys)

Function vFolderFormat Global String sFolderName Returns String
Formats a foldername by first trimming it and after that by sticking a directory separator (/\) to the end if it doesn't have one there already.
The folder may contain a drive letter or UNC encoding.

Download



vwin32fh-20170905.zip fix parsefoldername if filename part also part of path
vwin32fh-20170411.zip Lot's of patches, DF19.0 support, it is now a library
vWin32fh package March 13 2007 20Kb fixed parsefoldername bug, added vParentPath function, vSelectSaveFile function
vWin32fh package March 10 2006 19Kb added a bunch of new CSIDL types
vWin32fh package feb 28 2005 16Kb
vWin32fh package (original) ~14kb zipfile

Subversion



http://svn.vdf-guidance.com/vwin32fh/trunk/

Project Page



http://projects.vdf-guidance.com/projects/vwin32fh-windows-file-handling

Addendum



If you want to use the demo application under VDF8/VDF9 then please make the following changes:
Insert the following (or a ws of your choice) in the demo src

replace
use dfpanel
use dfbase

with
use globalallent
use DFAbout


#REPLACE CURRENT$WORKSPACE "yourworkspace.co"
Register_Object Client_Area

1) use package for application workspace
Use cApplication.pkg



2) Set date attributes as needed
Set_Date_Attribute sysdate4_State to dftrue 
Set_Date_Attribute Date4_State    to dftrue 
Set_Date_Attribute epoch_value    to 60 


3) Application Workspace - help type and name
Object oApplication is a cApplication
    Procedure OnCreate
	    Send DoOpenWorkspace CURRENT$WORKSPACE
    End_Procedure
    Set peHelpType to htHtmlHelp
    Set psHelpFile to 'KFPhelp.chm'
    Set pbEnterKeyAsTabKey to True
    Set psCompany to "Kirk Freeport"
    Set psProduct to "Kirknet"
    Set psVersion to "1.0"
    Set psProgram to (Module_Name(Self))
End_Object  // oApplication


Thanks to Dave Robinson for these notes.