|
↓このようなコードでテストしてみましたが、うまくいきましたよ。
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function ShellExecute Lib "shell32" Alias _
"ShellExecuteA" (ByVal hWnd&, ByVal lpOperation$, ByVal lpFile$, _
ByVal lpParameters$, ByVal lpDirectory$, ByVal nShowCmd&) As Long
Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal PROCESS As Long, lpExitCode As Long) As Long
Const SW_SHOW = 5
Sub Test_同期処理()
Dim hWnd As Long, INST As Long, PROCESS As Long
Dim MODORITI As Long, ENDWORK As Long
Const F_name As String = _
"C:\Documents and Settings\User\My Documents\Test.txt"
hWnd = GetForegroundWindow()
INST = ShellExecute(hWnd, "Open", "Notepad.exe", F_name, "", SW_SHOW)
PROCESS = OpenProcess(1024 Or 1048576, True, INST)
Do While 1
MODORITI = GetExitCodeProcess(PROCESS, ENDWORK)
If ENDWORK <> 259 Then Exit Do
Loop
MsgBox "同期処理は成功しました", 64
End Sub
|
|