WINAPI Filehandlingby Wil van Antwerpen
Windows FilehandlingThe 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:
Function vRemoveDirectory Global String sFolder Returns Integer With this function one can remove a directory. returns:
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![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Subversionhttp://svn.vdf-guidance.com/vwin32fh/trunk/ Project Pagehttp://projects.vdf-guidance.com/projects/vwin32fh-windows-file-handling AddendumIf 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. |
|||||||||||
Copyright © 1999 - 2025 VDF-GUIdance on all material published, for details see our Disclaimer. |