Article View: pl.comp.lang.vbasic
Article #92629Re: [VB6] Sprawdzenie procesu?
From: Barney Gumble
Date: Fri, 04 Nov 2005 21:06
Date: Fri, 04 Nov 2005 21:06
84 lines
3713 bytes
3713 bytes
Dodaj kod do nowego modulu:
'Kod start----------------------------->
Option Explicit
Private Const SW_HIDE = 0
Private Const SW_SHOWNORMAL = 1
Private Const SW_NORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_MAXIMIZE = 3
Private Const SW_SHOWNOACTIVATE = 4
Private Const SW_SHOW = 5
Private Const SW_MINIMIZE = 6
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_RESTORE = 9
Private Const SW_SHOWDEFAULT = 10
Private Const SW_MAX = 10
Private Declare Function apiFindWindow Lib "user32" Alias _
"FindWindowA" (ByVal strClass As String, _
ByVal lpWindow As String) As Long
Private Declare Function apiSendMessage Lib "user32" Alias _
"SendMessageA" (ByVal Hwnd As Long, ByVal Msg As Long, ByVal _
wParam As Long, lParam As Long) As Long
Private Declare Function apiSetForegroundWindow Lib "user32" Alias _
"SetForegroundWindow" (ByVal Hwnd As Long) As Long
Private Declare Function apiShowWindow Lib "user32" Alias _
"ShowWindow" (ByVal Hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function apiIsIconic Lib "user32" Alias _
"IsIconic" (ByVal Hwnd As Long) As Long
Private Sub TestIt()
Print fIsAppRunning("word")
End Sub
Function fIsAppRunning(ByVal strAppName As String, _
Optional fActivate As Boolean) As Boolean
Dim lngH As Long, strClassName As String
Dim lngX As Long, lngTmp As Long
Const WM_USER = 1024
On Local Error GoTo fIsAppRunning_Err
fIsAppRunning = False
Select Case LCase$(strAppName)
Case "excel": strClassName = "XLMain"
Case "word": strClassName = "OpusApp"
Case "access": strClassName = "OMain"
Case "powerpoint95": strClassName = "PP7FrameClass"
Case "powerpoint97": strClassName = "PP97FrameClass"
Case "notepad": strClassName = "NOTEPAD"
Case "paintbrush": strClassName = "pbParent"
Case "wordpad": strClassName = "WordPadClass"
Case Else: strClassName = ""
End Select
If strClassName = "" Then
lngH = apiFindWindow(vbNullString, strAppName)
Else
lngH = apiFindWindow(strClassName, vbNullString)
End If
If lngH <> 0 Then
apiSendMessage lngH, WM_USER + 18, 0, 0
lngX = apiIsIconic(lngH)
If lngX <> 0 Then
lngTmp = apiShowWindow(lngH, SW_SHOWNORMAL)
End If
If fActivate Then
lngTmp = apiSetForegroundWindow(lngH)
End If
fIsAppRunning = True
End If
fIsAppRunning_Exit:
Exit Function
fIsAppRunning_Err:
fIsAppRunning = False
Resume fIsAppRunning_Exit
End Function
'kod koniec <-----------------------------
Technical Details
Message-ID:
<436bcd6d$0$8862$edfadb0f@dread14.news.tele.dk>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news2.icm.edu.pl!news.nask.pl!news.nask.org.pl!newsfeed00.sul.t-online.de!t-online.de!news.tele.dk!not-for-mailReferences:
<dkfffh$3r2$1@news.interia.pl> <dkfrol$9o4$1@atlantis.news.tpi.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news2.icm.edu.pl!news.nask.pl!news.nask.org.pl!newsfeed00.sul.t-online.de!t-online.de!news.tele.dk!not-for-mail Date: Fri, 04 Nov 2005 22:06:53 +0100 From: Barney Gumble <nospam@4.me> User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: pl.comp.lang.vbasic Subject: Re: [VB6] Sprawdzenie procesu? References: <dkfffh$3r2$1@news.interia.pl> <dkfrol$9o4$1@atlantis.news.tpi.pl> In-Reply-To: <dkfrol$9o4$1@atlantis.news.tpi.pl> Lines: 84 Message-ID: <436bcd6d$0$8862$edfadb0f@dread14.news.tele.dk> Organization: TDC Totalloesninger NNTP-Posting-Host: 83.89.41.225 X-Trace: 1131138413 dread14.news.tele.dk 8862 83.89.41.225:46819 X-Complaints-To: abuse@post.tele.dk Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit