home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / FL_FindFile_vb________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2001-08-27  |  2.0 KB  |  72 lines

  1. ' Copyright
  2. ' Microsoft Corporation
  3. ' All rights reserved
  4.  
  5. ' FindFile.vb
  6.  
  7. Imports System
  8. Imports System.Runtime.InteropServices
  9.  
  10. 'typedef struct _WIN32_FIND_DATA 
  11. '{
  12. '  DWORD    dwFileAttributes; 
  13. '  FILETIME ftCreationTime; 
  14. '  FILETIME ftLastAccessTime; 
  15. '  FILETIME ftLastWriteTime; 
  16. '  DWORD    nFileSizeHigh; 
  17. '  DWORD    nFileSizeLow; 
  18. '  DWORD    dwReserved0; 
  19. '  DWORD    dwReserved1; 
  20. '  TCHAR    cFileName[ MAX_PATH ]; 
  21. '  TCHAR    cAlternateFileName[ 14 ]; 
  22. '} WIN32_FIND_DATA, *PWIN32_FIND_DATA; 
  23.  
  24. < StructLayout( LayoutKind.Sequential, CharSet := CharSet.Auto )> _
  25. Public Class FindData
  26.  
  27.    Public fileAttributes As Integer = 0
  28.    
  29.    ' creationTime was a by-value FILETIME structure
  30.    Public creationTime_lowDateTime As Integer = 0
  31.    Public creationTime_highDateTime As Integer = 0
  32.    
  33.    ' lastAccessTime was a by-value FILETIME structure
  34.    Public lastAccessTime_lowDateTime As Integer = 0
  35.    Public lastAccessTime_highDateTime As Integer = 0
  36.    
  37.    ' lastWriteTime was a by-value FILETIME structure
  38.    Public lastWriteTime_lowDateTime As Integer = 0
  39.    Public lastWriteTime_highDateTime As Integer = 0
  40.    
  41.    Public nFileSizeHigh As Integer = 0
  42.    Public nFileSizeLow As Integer = 0
  43.    Public dwReserved0 As Integer = 0
  44.    Public dwReserved1 As Integer = 0
  45.    
  46.    < MarshalAs( UnmanagedType.ByValTStr, SizeConst := 256 )> _
  47.    Public fileName As String = Nothing
  48.    
  49.    < MarshalAs( UnmanagedType.ByValTStr, SizeConst := 14 )> _
  50.    Public alternateFileName As String = Nothing
  51.    
  52. End Class 'FindData
  53.  
  54. Public Class LibWrap
  55.    
  56.     ' HANDLE FindFirstFile(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData)
  57.     
  58.     Declare Auto Function FindFirstFile Lib "Kernel32.dll" _
  59.         ( ByVal fileName As String, <[In], Out> ByVal findFileData As FindData ) As IntPtr
  60.    
  61. End Class 'LibWrap
  62.  
  63. Public Class App
  64.    Public Shared Sub Main()
  65.    
  66.       Dim fd As New FindData()
  67.       LibWrap.FindFirstFile( "C:\*", fd )
  68.       Console.WriteLine( "The first file: {0}", fd.fileName )
  69.       
  70.    End Sub 'Main
  71. End Class 'App
  72.