投稿日 | : 2003/07/05(Sat) 16:35 |
投稿者 | : Say |
Eメール | : |
URL | : |
タイトル | : Re^5: VBから読込み専用でImaging起動 |
>FindWindowにて動作中のImagingを監視しようと考えましたが、Imagingにはクラス名が
> なく監視する事が出来ませんでした。
だったらWindows Captionから拾えば?
たとえばこう。
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Dim strBMPpath(7) As String
Dim strWinCaption(7) As String
Private Sub Command1_Click()
Dim lngHwnd As Long
If List1.ListIndex >= 0 Then
Call sOpenImaging(strBMPpath(List1.ListIndex))
lngHwnd = 0&
Do While lngHwnd = 0&
lngHwnd = FindWindow(vbNullString, strWinCaption(List1.ListIndex))
DoEvents
Loop
List2.AddItem strWinCaption(List1.ListIndex)
List2.ItemData(List2.NewIndex) = List1.ListIndex
List3.AddItem lngHwnd
End If
End Sub
Private Sub sOpenImaging(ByVal ImgFile As String)
Dim Ret As Long
Dim MyAttr As Integer
MyAttr = GetAttr(ImgFile)
If MyAttr <> vbReadOnly Then
SetAttr ImgFile, vbReadOnly
End If
Ret = ShellExecute(Me.hwnd, "Open", "kodakimg.exe", _
ImgFile, vbNullString, 1&)
'Sleep 1000
'SetAttr ImgFile, MyAttr
End Sub
Private Sub Form_Load()
Dim i As Long
Me.Show
List1.AddItem "ABC.BMP"
List1.AddItem "あいう.bmp"
List1.AddItem "2003.bmp"
List1.AddItem "てすと.bmp"
List1.AddItem "Test2.bmp"
List1.AddItem "おひるね.bmp"
List1.AddItem "猫と少女.bmp"
List1.AddItem "なんかの地図.bmp"
For i = 0 To 7
strBMPpath(i) = App.Path & "\" & List1.List(i)
strWinCaption(i) = List1.List(i) & " - イメージング (読み取り専用)"
Next
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim i As Long
Dim lngHwnd As Long
Dim ImgFile As String
Dim strBuffer As String
If List2.ListCount > 0 Then
For i = List2.ListCount - 1 To 0 Step -1
strBuffer = List2.List(i)
lngHwnd = FindWindow(vbNullString, strBuffer)
If lngHwnd = 0 Then
ImgFile = strBMPpath(List2.ItemData(i))
SetAttr ImgFile, vbNormal
List2.RemoveItem i
List3.RemoveItem i
End If
DoEvents
Next
End If
End Sub