コメント |
↓Microsoft ドキュメント
http://msdn.microsoft.com/ja-jp/library/system.runtime.interopservices.structlayoutattribute.charset.aspx(引き渡す際のキャラクタセット変換)
↓Console.WriteLine の書式指定
http://msdn.microsoft.com/ja-jp/library/txafckwd.aspx
@DIV
Imports System.Text
Imports System.Runtime.InteropServices
Module MyModule
REM ********************************************************
REM * WIN32_FIND_DATA 構造体と同等のクラス定義
REM ********************************************************
< StructLayout( LayoutKind.Sequential, CharSet := CharSet.Ansi )> _
Public Class WIN32_FIND_DATA
Public fileAttributes As Integer = 0
Public creationTime_lowDateTime As Integer = 0
Public creationTime_highDateTime As Integer = 0
Public lastAccessTime_lowDateTime As Integer = 0
Public lastAccessTime_highDateTime As Integer = 0
Public lastWriteTime_lowDateTime As Integer = 0
Public lastWriteTime_highDateTime As Integer = 0
Public nFileSizeHigh As Integer = 0
Public nFileSizeLow As Integer = 0
Public dwReserved0 As Integer = 0
Public dwReserved1 As Integer = 0
< MarshalAs( UnmanagedType.ByValTStr, SizeConst := 256 )> _
Public fileName As String = Nothing
< MarshalAs( UnmanagedType.ByValTStr, SizeConst := 14 )> _
Public alternateFileName As String = Nothing
End Class
REM ********************************************************
REM * DLL 内 関数宣言
REM ********************************************************
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" ( _
ByVal fileName As String, _
<[In], Out> ByVal findFileData As WIN32_FIND_DATA _
) As Integer
Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" ( _
ByVal hFindFile As Integer, _
<[In], Out> ByVal findFileData As WIN32_FIND_DATA _
) As Integer
REM ********************************************************
REM * 実行
REM ********************************************************
Sub Main()
Dim wfd As New WIN32_FIND_DATA()
Dim handle As Integer
Dim ret As Integer
handle = FindFirstFile( "C:\tmp\*.*", wfd )
ret = -1
Do While( handle <> -1 and ret <> 0 )
Call System.Console.WriteLine( "{1,-10} {0}", wfd.fileName, wfd.nFileSizeLow )
ret = FindNextFile( handle, wfd )
Loop
End Sub
End Module
@END
|