「このプログラムは応答していません」と表示されてしまいます
Posted: 2006年7月28日(金) 23:37
以下のようなプログラムで、D:\test1フォルダーを監視して、pdfが投げ込まれたらd:\test2フォルダーへmoveさせようとしています。監視してMoveすること自体は正常に動作してくれていますが、メインウィンドウで"閉じる"をクリックすると、「このプログラムは応答していません」と表示されてしまいます。
無限ループの組み方が悪いのではないかと思いますが、どなたかアドバイスを戴けけないでしょうか?
よろしくお願い致します。
------------------------------------------------------------------------------------
' ここから下は、イベントプロシージャを記述するための領域になります。
Sub MainWnd_Destroy()
test_DestroyObjects()
PostQuitMessage(0)
End Sub
Sub MainWnd_Create(ByRef CreateStruct As CREATESTRUCT)
SetTimer(hMainWnd,1,1,AddressOf(fff) As DWord) 'タイマーの設定
End Sub
Sub fff()
Dim File1 As String
File1="D:\test1\*.pdf" 'pdf検索用
dim File2 as string
dim File3 as string
Dim wfd1 As WIN32_FIND_DATA '構造体: WIN32_FIND_DATA
Dim hFind As VoidPtr
dim drv[2] As Byte
dim path[255] As Byte
dim fname[255] As Byte
dim ext[63] As Byte
dim i as long
i=1
dim filepath_F as string
Dim Ret As Long
KillTimer(hMainWnd,1)
While i=1
hFind = FindFirstFile(File1,wfd1)
If hFind=INVALID_HANDLE_VALUE Then
' MessageBox(hMainWnd,File1+"が見つからない","",MB_OK)
Else
File2=wfd1.cFileName '構造体: WIN32_FIND_DATAから検索結果を取得
File2="D:\test1\"+File2 '検索結果:フルパス
_splitpath(StrPtr(File2),drv,path,fname,ext)
File3=fname '単体ファイル名
' MessageBox(hMainWnd,File2,"フルパス",MB_OK)
' MessageBox(hMainWnd,fname,"ファイル名単体",MB_OK)
filepath_F="D:\test2\"+File3+".pdf"
Ret=MoveFile(File2, filepath_F)
FindClose(hFind)
End If
Sleep(1000)
Wend
End sub
無限ループの組み方が悪いのではないかと思いますが、どなたかアドバイスを戴けけないでしょうか?
よろしくお願い致します。
------------------------------------------------------------------------------------
' ここから下は、イベントプロシージャを記述するための領域になります。
Sub MainWnd_Destroy()
test_DestroyObjects()
PostQuitMessage(0)
End Sub
Sub MainWnd_Create(ByRef CreateStruct As CREATESTRUCT)
SetTimer(hMainWnd,1,1,AddressOf(fff) As DWord) 'タイマーの設定
End Sub
Sub fff()
Dim File1 As String
File1="D:\test1\*.pdf" 'pdf検索用
dim File2 as string
dim File3 as string
Dim wfd1 As WIN32_FIND_DATA '構造体: WIN32_FIND_DATA
Dim hFind As VoidPtr
dim drv[2] As Byte
dim path[255] As Byte
dim fname[255] As Byte
dim ext[63] As Byte
dim i as long
i=1
dim filepath_F as string
Dim Ret As Long
KillTimer(hMainWnd,1)
While i=1
hFind = FindFirstFile(File1,wfd1)
If hFind=INVALID_HANDLE_VALUE Then
' MessageBox(hMainWnd,File1+"が見つからない","",MB_OK)
Else
File2=wfd1.cFileName '構造体: WIN32_FIND_DATAから検索結果を取得
File2="D:\test1\"+File2 '検索結果:フルパス
_splitpath(StrPtr(File2),drv,path,fname,ext)
File3=fname '単体ファイル名
' MessageBox(hMainWnd,File2,"フルパス",MB_OK)
' MessageBox(hMainWnd,fname,"ファイル名単体",MB_OK)
filepath_F="D:\test2\"+File3+".pdf"
Ret=MoveFile(File2, filepath_F)
FindClose(hFind)
End If
Sleep(1000)
Wend
End sub