I am maintaining code that is used to traverse through a directory on a Pcocket PC handheld scanner, and detect if there is a file available to be uploaded. The function below is the code that traverses through the directories:

Code:
Public Function CheckFileExistence(strFileName As String) As Boolean
    On Error GoTo ErrHandler
    
    Dim bytBuffer(200000) As Byte
    Dim lngFileHandle As Long
    Dim lngBytesRead As Long
    Dim typFindFileData As CE_FIND_DATA
    Dim intFreeFileID As Integer
    Dim intWriteLoop As Integer
    Dim strRemoteFileName As String
            
    strRemoteFileName = strFileName
    
    'Check the existence of the file on the device
    lngFileHandle = CeFindFirstFile(strRemoteFileName, typFindFileData)
    
    If lngFileHandle = INVALID_HANDLE Then
        CheckFileExistence = False
    Else
        CheckFileExistence = True
    End If
    
    Exit Function
ErrHandler:
    Err.Raise CeGetLastError, Err.Source, Err.Description
End Function
I did tweaked some code earlier that SHOULD not have anything to do with as it is in the Form Load sub procedure and does not update any global variables.

Old Code:
Code:
    intResponse = MsgBox("Is the scanner connected to the PC?", vbYesNo + vbApplicationModal + vbQuestion, "Confirm")
    If intResponse = vbNo Then End
    
    intRetVal = CeRapiInit()
    
    If intRetVal <> INIT_SUCCESS Then
        MsgBox "Failed to initialise RAPI with device with error " & _
        CeGetLastError
        CeRapiUninit
        End
    End If
New Code:
Code:
If CeGetDeviceId() = False Then
    Dim num As Integer
    num = MsgBox("Handheld scanner not detected.  Exiting ScanTransferV3 application.", vbCritical, "CeGetDeviceId() Failed")
    End
End If
I'm lost on this one?? Thanks for any suggestions or help!