elizarrj
asked on
My VB6 Program quit finding Index>dat files under Windows 7 and Windows 8
I have a cleaning program similar to CCleaner that recently stopped finding index.dat files on my PC. CCleaner finds them but my program stopped. I included my search routine. My program works with Vista and below. It had worked with Windows 7 previously. Just not sure when it stopped.
ASKER
I can do a dir of index.dat at the command prompt in administrator mode and I see the index.dat programs. I run my program under administrator mode I still don't see the index.dat
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am finding the files through API. I thought, and does work with Vista and below that it does find Hidden/System/Archive etc. Is there a better way and a much faster serach function?
I call my subroutine like
call getfiles("C:\","*.log")
Public Sub GetFiles(ByVal Start_Dir As String, ByVal Pattern As String)
On Error GoTo ErrorHandler
Const MAXDWORD = 2 ^ 32
Dim dir_names() As String
Dim num_dirs As Integer
Dim i As Integer
Dim FName As String
Dim search_handle As Long
Dim file_data As WIN32_FIND_DATA
Dim file_size As Double
Dim DeleteName As String
Dim retVal As Integer
' Get the matching files in this directory.
' Get the first file.
search_handle = FindFirstFile( _
Start_Dir & Pattern, file_data)
If search_handle <> INVALID_HANDLE_VALUE Then
' Get the rest of the files.
Do
FName = file_data.cFileName
FName = Left$(FName, InStr(FName, Chr$(0)) - 1)
file_size = (file_data.nFileSizeHigh * MAXDWORD) + file_data.nFileSizeLow
If file_size > 0 Then
DoEvents
total_size = total_size + file_size
DeleteName = Start_Dir & FName
retVal = SetAttributes(DeleteName, FILE_ATTRIBUTE_NORMAL)
If Check2Exclude(DeleteName) = True Then
frmPrivacy.lstResults.List Items.Add , , DeleteName & Chr$(32) & GetMsg(914)
Else
If TestMode = True Then
frmPrivacy.lstResults.List Items.Add , , GetMsg(887) & Chr$(32) & GetMsg(913) & Chr$(32) & DeleteName & Chr$(32) & GetMsg(888)
Else
With frmPrivacy.cShred
.p_Attributes = 1
.p_ShredMethod = frmPrivacy.cboShredType.Te xt
.p_Passes = Passes
.p_SourceFile = DeleteName
.RenameFlag = True
.DetermineShredMethod
End With
End If
End If
Else
DeleteName = Start_Dir & FName
DoEvents
retVal = SetAttributes(DeleteName, FILE_ATTRIBUTE_NORMAL)
If Check2Exclude(DeleteName) = True Then
frmPrivacy.lstResults.List Items.Add , , DeleteName & Chr$(32) & GetMsg(914)
Else
If TestMode = True Then
frmPrivacy.lstResults.List Items.Add , , GetMsg(887) & Chr$(32) & GetMsg(913) & Chr$(32) & DeleteName & Chr$(32) & GetMsg(888)
Else
With frmPrivacy.cShred
.p_Attributes = 1
.p_ShredMethod = frmPrivacy.cboShredType.Te xt
.p_Passes = Passes
.p_SourceFile = DeleteName
.RenameFlag = True
.DetermineShredMethod
End With
End If
End If
End If
' Get the next file.
If FindNextFile(search_handle , file_data) = 0 Then Exit Do
Loop
' Close the file search hanlde.
FindClose search_handle
End If
' Get the list of subdirectories.
search_handle = FindFirstFile( _
Start_Dir & "*.*", file_data)
If search_handle <> INVALID_HANDLE_VALUE Then
' Get the rest of the files.
Do
If file_data.dwFileAttributes And DDL_DIRECTORY Then
FName = file_data.cFileName
FName = Left$(FName, InStr(FName, Chr$(0)) - 1)
If FName <> "." And FName <> ".." Then
num_dirs = num_dirs + 1
ReDim Preserve dir_names(1 To num_dirs)
dir_names(num_dirs) = FName
End If
End If
DoEvents
' Get the next file.
If FindNextFile(search_handle , file_data) = 0 Then Exit Do
Loop
' Close the file search handle.
FindClose search_handle
End If
' Close the file search handle.
FindClose search_handle
' Search the subdirectories.
For i = 1 To num_dirs
GetFiles Start_Dir & dir_names(i) & "\", Pattern
Next i
Exit Sub
ErrorHandler:
Call FormatLogMessage("DeleteMa nager", "GetFiles", "Subroutine", Err.Number & " - " & Err.Description, 440, vbCritical)
End Sub
I call my subroutine like
call getfiles("C:\","*.log")
Public Sub GetFiles(ByVal Start_Dir As String, ByVal Pattern As String)
On Error GoTo ErrorHandler
Const MAXDWORD = 2 ^ 32
Dim dir_names() As String
Dim num_dirs As Integer
Dim i As Integer
Dim FName As String
Dim search_handle As Long
Dim file_data As WIN32_FIND_DATA
Dim file_size As Double
Dim DeleteName As String
Dim retVal As Integer
' Get the matching files in this directory.
' Get the first file.
search_handle = FindFirstFile( _
Start_Dir & Pattern, file_data)
If search_handle <> INVALID_HANDLE_VALUE Then
' Get the rest of the files.
Do
FName = file_data.cFileName
FName = Left$(FName, InStr(FName, Chr$(0)) - 1)
file_size = (file_data.nFileSizeHigh * MAXDWORD) + file_data.nFileSizeLow
If file_size > 0 Then
DoEvents
total_size = total_size + file_size
DeleteName = Start_Dir & FName
retVal = SetAttributes(DeleteName, FILE_ATTRIBUTE_NORMAL)
If Check2Exclude(DeleteName) = True Then
frmPrivacy.lstResults.List
Else
If TestMode = True Then
frmPrivacy.lstResults.List
Else
With frmPrivacy.cShred
.p_Attributes = 1
.p_ShredMethod = frmPrivacy.cboShredType.Te
.p_Passes = Passes
.p_SourceFile = DeleteName
.RenameFlag = True
.DetermineShredMethod
End With
End If
End If
Else
DeleteName = Start_Dir & FName
DoEvents
retVal = SetAttributes(DeleteName, FILE_ATTRIBUTE_NORMAL)
If Check2Exclude(DeleteName) = True Then
frmPrivacy.lstResults.List
Else
If TestMode = True Then
frmPrivacy.lstResults.List
Else
With frmPrivacy.cShred
.p_Attributes = 1
.p_ShredMethod = frmPrivacy.cboShredType.Te
.p_Passes = Passes
.p_SourceFile = DeleteName
.RenameFlag = True
.DetermineShredMethod
End With
End If
End If
End If
' Get the next file.
If FindNextFile(search_handle
Loop
' Close the file search hanlde.
FindClose search_handle
End If
' Get the list of subdirectories.
search_handle = FindFirstFile( _
Start_Dir & "*.*", file_data)
If search_handle <> INVALID_HANDLE_VALUE Then
' Get the rest of the files.
Do
If file_data.dwFileAttributes
FName = file_data.cFileName
FName = Left$(FName, InStr(FName, Chr$(0)) - 1)
If FName <> "." And FName <> ".." Then
num_dirs = num_dirs + 1
ReDim Preserve dir_names(1 To num_dirs)
dir_names(num_dirs) = FName
End If
End If
DoEvents
' Get the next file.
If FindNextFile(search_handle
Loop
' Close the file search handle.
FindClose search_handle
End If
' Close the file search handle.
FindClose search_handle
' Search the subdirectories.
For i = 1 To num_dirs
GetFiles Start_Dir & dir_names(i) & "\", Pattern
Next i
Exit Sub
ErrorHandler:
Call FormatLogMessage("DeleteMa
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Found my answer. Should have read msdn. I.E. 10 went to using container.dat files.
ASKER