|  | 		    
					
        
         
          
         
	
          | |  | proccess-check i WIN2000 Fra : Lars Nielsen
 | 
 Dato :  06-09-01 10:55
 | 
 |  | Hej
 
 Er der en der har en god idé til hvordan man kan lave et lille program som
 checker om en process (ntvdm.exe) er aktiv eller ej på en WIN2000 server ?
 
 
 På forhånd tak
 Lars Nielsen
 
 
 
 
 
 |  |  | 
  Jens (06-09-2001) 
 
	
          | |  | Kommentar Fra : Jens
 | 
 Dato :  06-09-01 11:48
 | 
 |  | Prøv dette
 
 Option Explicit
 
 Private Declare Function FindWindowEx _
 Lib "user32" Alias "FindWindowExA" ( _
 ByVal hWnd1 As Long, _
 ByVal hWnd2 As Long, _
 ByVal lpsz1 As String, _
 ByVal lpsz2 As String) As Long
 
 Private Function Running(ByVal Program As String) As Boolean
 Dim hWnd As Long
 
 hWnd = FindWindowEx(0&, 0&, Program, Me.Caption)
 Running = (hWnd = Me.hWnd)
 End Function
 
 
 Private Sub Form_Load()
 
 MsgBox Running("ntvdm.exe")
 
 End
 
 End Sub
 
 
 
 
 
 |  |  | 
  Lars Nielsen (06-09-2001) 
 
	
          | |  | Kommentar Fra : Lars Nielsen
 | 
 Dato :  06-09-01 14:03
 | 
 |  | 
 
            Hej Jens
 Programmet kører godt nok, men uanset hvad jeg tester på, så får jeg svaret
 : "False"    Hilsen Lars
 "Jens" <til@infojens.dk> wrote in message
 news:3b975456$0$257$edfadb0f@dspool01.news.tele.dk...
 > Prøv dette
 >
 > Option Explicit
 >
 > Private Declare Function FindWindowEx _
 >  Lib "user32" Alias "FindWindowExA" ( _
 >  ByVal hWnd1 As Long, _
 >  ByVal hWnd2 As Long, _
 >  ByVal lpsz1 As String, _
 >  ByVal lpsz2 As String) As Long
 >
 > Private Function Running(ByVal Program As String) As Boolean
 >     Dim hWnd As Long
 >
 >     hWnd = FindWindowEx(0&, 0&, Program, Me.Caption)
 >     Running = (hWnd = Me.hWnd)
 > End Function
 >
 >
 > Private Sub Form_Load()
 >
 >   MsgBox Running("ntvdm.exe")
 >
 >   End
 >
 > End Sub
 >
 >
 >
            
             |  |  | 
   Jens (06-09-2001) 
 
	
          | |  | Kommentar Fra : Jens
 | 
 Dato :  06-09-01 18:17
 | 
 |  | Vi prøver noget andet......her er et udklip fra en af mine class filer som
 lukker programmer prøv lige den, så kan du altid lave den lidt om
 
 Option Explicit
 
 Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
 lpClassName As String, ByVal lpWindowName As String) As Long
 Private Declare Function PostMessage Lib "user32" Alias "PostMessageA"
 (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
 Any) As Long
 Private Const WM_CLOSE = &H10
 Dim lHwnd As Long
 Dim lRetVal As Long
 
 Public Function Luk(ByVal ProgramCaption As String) As Boolean
 
 lHwnd = FindWindow(vbNullString, ProgramCaption)
 If lHwnd <> 0 Then
 lRetVal = PostMessage(lHwnd, WM_CLOSE, 0&, 0&)
 End If
 
 End Function
 
 
 
 
 
 |  |  | 
    Lars Nielsen (06-09-2001) 
 
	
          | |  | Kommentar Fra : Lars Nielsen
 | 
 Dato :  06-09-01 22:36
 | 
 |  | Hej  igen
 
 Jeg er bange for at jeg ikke har forklaret mig ordentligt.
 Jeg har brug for at kunne checke om en procces i "Task Manageren" kører.
 
 Hilsen Lars
 
 "Jens" <til@infojens.dk> skrev i en meddelelse
 news:3b97af7b$0$264$edfadb0f@dspool01.news.tele.dk...
 > Vi prøver noget andet......her er et udklip fra en af mine class filer som
 > lukker programmer prøv lige den, så kan du altid lave den lidt om
 >
 > Option Explicit
 >
 > Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
 (ByVal
 > lpClassName As String, ByVal lpWindowName As String) As Long
 > Private Declare Function PostMessage Lib "user32" Alias "PostMessageA"
 > (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
 > Any) As Long
 > Private Const WM_CLOSE = &H10
 > Dim lHwnd As Long
 > Dim lRetVal As Long
 >
 > Public Function Luk(ByVal ProgramCaption As String) As Boolean
 >
 >     lHwnd = FindWindow(vbNullString, ProgramCaption)
 >     If lHwnd <> 0 Then
 >         lRetVal = PostMessage(lHwnd, WM_CLOSE, 0&, 0&)
 >     End If
 >
 > End Function
 >
 >
 >
 
 
 
 
 |  |  | 
 |  |