home *** CD-ROM | disk | FTP | other *** search
- Option Explicit
-
- Dim strDir As String
- Dim intDirNameLength As Integer
-
- Declare Function KRN_GetWindowsDirectory Lib "Kernel" Alias "GetWindowsDirectory" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
- Declare Function KRN_GetSystemDirectory Lib "Kernel" Alias "GetSystemDirectory" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
-
- Function CopyFile (strFileName As String, strDestination As String) As Integer
- '
- ' This routine will copy a file to a given destination.
- '
- CopyFile = False
-
- On Error GoTo CopyFile_ER
-
- FileCopy strFileName, strDestination
- Exit Function
-
- CopyFile_ER:
- CopyFile = Err
- strMsg = "Error in CopyFile, Error is " & Error
- strMsgTitle = "Copy File"
- Exit Function
- End Function
-
- Function FileExists (strFilePath As String) As Integer
- '
- ' This routine will check for the existence of a
- ' file by attempting an OPEN. It will return a TRUE
- ' value if the file exists, FALSE otherwise.
- '
- Dim nFile As Integer
-
- nFile = FreeFile
-
- On Error Resume Next
- Open strFilePath For Input As nFile
- If Err = 0 Then
- FileExists = True
- Else
- FileExists = False
- End If
- Close nFile
- End Function
-
- Function GetWinDir () As String
- '
- ' This routine will find and return the users windows
- ' directory.
- '
- strDir = String$(145, 0) ' Size Buffer
- intDirNameLength = KRN_GetWindowsDirectory(strDir, 145) ' Make API Call
- strDir = Left$(strDir, intDirNameLength) ' Trim Buffer
-
- If Right$(strDir, 1) <> "\" Then ' Add \ if necessary
- GetWinDir = strDir + "\"
- Else
- GetWinDir = strDir
- End If
- End Function
-
- Function GetWinSysDir () As String
- '
- ' This routine will return the users windows system
- ' directory
- '
- strDir = String$(145, 0) ' Size Buffer
- intDirNameLength = KRN_GetSystemDirectory(strDir, 145) ' Make API Call
- strDir = Left$(strDir, intDirNameLength) ' Trim Buffer
-
- If Right$(strDir, 1) <> "\" Then ' Add \ if necessary
- GetWinSysDir = strDir + "\"
- Else
- GetWinSysDir = strDir
- End If
- End Function
-
-