Visual Basic İle Arama Yapmak Nisan 27, 2008
Posted by programlama2000 in Visual Basic 6.0.trackback

Private Const MAX_PATH = 260
Private Const INVALID_HANDLE_VALUE = -1
Private Const FILE_ATTRIBUTE_DIRECTORY = &H10
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Private Declare Function FindFirstFile Lib “kernel32″ Alias “FindFirstFileA” (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindNextFile Lib “kernel32″ Alias “FindNextFileA” (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindClose Lib “kernel32″ (ByVal hFindFile As Long) As Long
Public Sub FindFiles(strRootFolder As String, strFolder As String, strFile As String)
On Error Resume Next
Dim lngSearchHandle As Long
Dim udtFindData As WIN32_FIND_DATA
Dim strTemp As String, lngRet As Long
If Right$(strRootFolder, 1) <> “” Then strRootFolder = strRootFolder & “”
lngSearchHandle = FindFirstFile(strRootFolder & “*”, udtFindData)
If lngSearchHandle = INVALID_HANDLE_VALUE Then Exit Sub
lngRet = 1
Do While lngRet <> 0
strTemp = TrimNulls(udtFindData.cFileName)
sakir = TrimNulls(udtFindData.cAlternate)
If (udtFindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then
If strTemp <> “.” And strTemp <> “..” Then
Call FindFiles(strRootFolder & strTemp, strFolder, strFile)
End If
Else
If (strRootFolder Like strFolder) Then
If (strTemp Like strFile) Then
List1.AddItem strRootFolder & strTemp
End If
End If
End If
lngRet = FindNextFile(lngSearchHandle, udtFindData)
Loop
Call FindClose(lngSearchHandle)
End Sub
Private Function TrimNulls(strString As String) As String
Dim l As Long
l = InStr(1, strString, Chr(0))
If l = 1 Then
TrimNulls = “”
ElseIf l > 0 Then
TrimNulls = Left$(strString, l – 1)
Else
TrimNulls = strString
End If
End Function
Private Sub Command1_Click()
List1.Clear
FindFiles Text1.Text, “*”, “*.” & Text2.Text
End Sub
KOD INDIR
1 : http://rapidshare.com/files/96166513/dosya_arama_Alt_dizinlerde_dahil.rar.html
2 : http://s1.dosya.cc/dosyaaramaAltdizinlerdedahil.rar.html
Yorumlar»
No comments yet — be the first.