The code below seems to work fine with Win9*, but with Win2k it doesn't. Anyone know why?

BTW: If you test it out you will need to look up the "Cache Name" of an image file in your Temporary Internet Files folder.
Then use that image file name instead of "image[1].gif"

Module:
VB Code:
  1. Option Explicit
  2. '//////////////////////////////////////////////////
  3. '// Determine Temporary Internet //////////////////
  4. '// Folder Location Declarations //////////////////
  5. '//////////////////////////////////////////////////
  6.  
  7. Private Type ShortItemId
  8.      cb As Long
  9.      abID As Byte
  10. End Type
  11.  
  12. Private Type ITEMIDLIST
  13.      mkid As ShortItemId
  14. End Type
  15.  
  16. ' Declare constants.
  17. Public Const CSIDL_INTERNET_CACHE = &H20
  18. 'Public Const CSIDL_TEMPLATES = &H15
  19. 'Public Const CSIDL_STARTMENU = &HB
  20. 'Public Const CSIDL_FAVORITES = &H6
  21. 'Public Const CSIDL_DESKTOPDIRECTORY = &H10
  22.  
  23. ' Declare API functions.
  24. Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
  25.    (ByVal pidl As Long, ByVal pszPath As String) As Long
  26.  
  27. Private Declare Function SHGetSpecialFolderLocation Lib _
  28.    "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder _
  29.    As Long, pidl As ITEMIDLIST) As Long
  30.    
  31. '//////////////////////////////////////////////////
  32. '///////////// Find File Declarations /////////////
  33. '//////////////////////////////////////////////////
  34.  
  35. Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
  36. Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
  37. Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
  38. Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
  39.  
  40. Const MAX_PATH = 260
  41. Const MAXDWORD = &HFFFF
  42. Const INVALID_HANDLE_VALUE = -1
  43. Const FILE_ATTRIBUTE_ARCHIVE = &H20
  44. Const FILE_ATTRIBUTE_DIRECTORY = &H10
  45. Const FILE_ATTRIBUTE_HIDDEN = &H2
  46. Const FILE_ATTRIBUTE_NORMAL = &H80
  47. Const FILE_ATTRIBUTE_READONLY = &H1
  48. Const FILE_ATTRIBUTE_SYSTEM = &H4
  49. Const FILE_ATTRIBUTE_TEMPORARY = &H100
  50.  
  51. Private Type FILETIME
  52.     dwLowDateTime As Long
  53.     dwHighDateTime As Long
  54. End Type
  55.  
  56. Private Type WIN32_FIND_DATA
  57.     dwFileAttributes As Long
  58.     ftCreationTime As FILETIME
  59.     ftLastAccessTime As FILETIME
  60.     ftLastWriteTime As FILETIME
  61.     nFileSizeHigh As Long
  62.     nFileSizeLow As Long
  63.     dwReserved0 As Long
  64.     dwReserved1 As Long
  65.     cFileName As String * MAX_PATH
  66.     cAlternate As String * 14
  67. End Type
  68.  
  69.  
  70.  
  71.  
  72. Public Function GetSpecialFolder(CSIDL As Long) As String
  73.  
  74.    Dim idlstr As Long
  75.    Dim sPath As String
  76.    Dim IDL As ITEMIDLIST
  77.  
  78.    Const NOERROR = 0
  79.    Const MAX_LENGTH = 260
  80.  
  81.    On Error GoTo Err_GetFolder
  82.  
  83.    ' Fill the idl structure with the specified folder item.
  84.    idlstr = SHGetSpecialFolderLocation _
  85.       (0, CSIDL, IDL)
  86.  
  87.    If idlstr = NOERROR Then
  88.  
  89.         ' Get the path from the idl list, and return
  90.         ' the folder with a slash at the end.
  91.         sPath = Space$(MAX_LENGTH)
  92.         idlstr = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath)
  93.  
  94.            If idlstr Then
  95.              GetSpecialFolder = Left$(sPath, InStr(sPath, Chr$(0)) _
  96.                - 1) '& "\"
  97.            End If
  98.  
  99.    End If
  100.  
  101. Exit_GetFolder:
  102.     Exit Function
  103. Err_GetFolder:
  104.     MsgBox Err.Description, vbCritical Or vbOKOnly
  105.     Resume Exit_GetFolder
  106.  
  107. End Function
  108.  
  109. Public Function StripNulls(OriginalStr As String) As String
  110.     If (InStr(OriginalStr, Chr(0)) > 0) Then
  111.         OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
  112.     End If
  113.     StripNulls = OriginalStr
  114. End Function
  115.  
  116. Public Function FindFilesAPI(path As String, SearchStr As String)
  117.     'KPD-Team 1999
  118.     'E-Mail: [email][email protected][/email]
  119.     'URL: [url]http://www.allapi.net/[/url]
  120.  
  121.     Dim FileName As String ' Walking filename variable...
  122.     Dim DirName As String ' SubDirectory Name
  123.     Dim dirNames() As String ' Buffer for directory name entries
  124.     Dim nDir As Integer ' Number of directories in this path
  125.     Dim i As Integer ' For-loop counter...
  126.     Dim hSearch As Long ' Search Handle
  127.     Dim WFD As WIN32_FIND_DATA
  128.     Dim Cont As Integer
  129.     If Right(path, 1) <> "\" Then path = path & "\"
  130.     ' Search for subdirectories.
  131.     nDir = 0
  132.     ReDim dirNames(nDir)
  133.     Cont = True
  134.     hSearch = FindFirstFile(path & "*", WFD)
  135.     If hSearch <> INVALID_HANDLE_VALUE Then
  136.         Do While Cont
  137.         DirName = StripNulls(WFD.cFileName)
  138.         ' Ignore the current and encompassing directories.
  139.         If (DirName <> ".") And (DirName <> "..") Then
  140.             ' Check for directory with bitwise comparison.
  141.             If GetFileAttributes(path & DirName) And FILE_ATTRIBUTE_DIRECTORY Then
  142.                 dirNames(nDir) = DirName
  143.                 nDir = nDir + 1
  144.                 ReDim Preserve dirNames(nDir)
  145.             End If
  146.         End If
  147.         Cont = FindNextFile(hSearch, WFD) 'Get next subdirectory.
  148.         Loop
  149.         Cont = FindClose(hSearch)
  150.     End If
  151.     ' Walk through this directory and sum file sizes.
  152.     hSearch = FindFirstFile(path & SearchStr, WFD)
  153.     Cont = True
  154.     If hSearch <> INVALID_HANDLE_VALUE Then
  155.         While Cont
  156.             FileName = StripNulls(WFD.cFileName)
  157.             If (FileName <> ".") And (FileName <> "..") Then
  158.                 FindFilesAPI = FindFilesAPI + (WFD.nFileSizeHigh * MAXDWORD) + WFD.nFileSizeLow
  159.                 Form1.picYahoo.Picture = LoadPicture(path & FileName)
  160.             End If
  161.             Cont = FindNextFile(hSearch, WFD) ' Get next file
  162.         Wend
  163.         Cont = FindClose(hSearch)
  164.     End If
  165.     ' If there are sub-directories...
  166.     If nDir > 0 Then
  167.         ' Recursively walk into them...
  168.         For i = 0 To nDir - 1
  169.             FindFilesAPI = FindFilesAPI + FindFilesAPI(path & dirNames(i) & "\", SearchStr)
  170.         Next i
  171.     End If
  172. End Function

Form: Command Button and Picture Box
VB Code:
  1. Option Explicit
  2.  
  3. Private Sub Command1_Click()
  4.     Dim picName As String
  5.     picName = "image[1].gif"
  6.     FindFilesAPI GetSpecialFolder(CSIDL_INTERNET_CACHE), picName
  7. End Sub