Question : How do I close Adobe Reader from within VB.NET

I have a program that will allow the user to "stamp" a PDF document with comments.  Of course, if the user is viewing the file (using Adobe Reader) the the system cannot save the "stamped" version of the document because it is opened by another user.

The program needs to find the instance of Adobe Reader that is running with the needed doc and close it so it can "stamp" the PDF doc.  

Does anyone out there know how to do this?

Answer : How do I close Adobe Reader from within VB.NET

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
 _
Private Shared Function FindWindow( _
     ByVal lpClassName As String, _
     ByVal lpWindowName As String) As IntPtr
End Function

 _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function


public const int WM_SYSCOMMAND = 0x0112;
public const int SC_CLOSE = 0xF060; 

    Dim nWnd As IntPtr
    Dim ceroIntPtr As New IntPtr(0)
    Dim Wnd_name as String

    Wnd_name= "Some App Name"
    nWnd = FindWindow(Nothing, Wnd_name)
    SendMessage(nWnd, WM_SYSCOMMAND, SC_CLOSE, 0)
Random Solutions  
 
programming4us programming4us