Thread View: comp.databases.ms-access
4 messages
4 total messages
Started by DHI
Thu, 22 Jul 1999 00:00
Get ProcessID for given task
Author: DHI
Date: Thu, 22 Jul 1999 00:00
Date: Thu, 22 Jul 1999 00:00
9 lines
716 bytes
716 bytes
Hi Folks, Well, it may be a bit off-topic but I need a function in my Access App. (properly a MFD-function) which returns the process-ID for a given task as shown in the Task Manager. Thanx in advance.. Regards Jeppe
Re: Get ProcessID for given task
Author: Hroi Sigurdsson
Date: Thu, 22 Jul 1999 00:00
Date: Thu, 22 Jul 1999 00:00
14 lines
1144 bytes
1144 bytes
DHI wrote: > > Hi Folks, > > Well, it may be a bit off-topic but I need a function in my Access > App. (properly a MFD-function) which returns the process-ID for a given > task as shown in the Task Manager. > Try dk.edb.programmering.basic -- Hroi Kristjan Sigurdsson hroi@get2net.dk "make world, not war."
Re: Get ProcessID for given task
Author: Dev Ashish
Date: Thu, 22 Jul 1999 00:00
Date: Thu, 22 Jul 1999 00:00
85 lines
3239 bytes
3239 bytes
Hi Jeppe,
Try something like this if you know the class name of theapp you're
looking for.
'************** Code Start ***************
Private Declare Function apiGetWindow Lib "user32" _
Alias "GetWindow" _
(ByVal hWnd As Long, _
ByVal wCmd As Long) _
As Long
Private Declare Function apiGetWindowThreadProcessId Lib "user32" _
Alias "GetWindowThreadProcessId" _
(ByVal hWnd As Long, _
lpdwProcessID As Long) _
As Long
Private Declare Function apiGetDesktopWindow Lib "user32" _
Alias "GetDesktopWindow" () _
As Long
Private Declare Function apiGetClassName Lib "user32" _
Alias "GetClassNameA" _
(ByVal hWnd As Long, _
ByVal lpClassname As String, _
ByVal nMaxCount As Long) _
As Long
Private Declare Function apiGetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) _
As Long
Private Const GW_CHILD = 5
Private Const GW_HWNDNEXT = 2
Private Const GWL_STYLE = (-16)
Private Const WS_VISIBLE = &H10000000
Private Const MAX_LEN = 255
Function fGetProcessID(ByVal strClassName As String) As Long
Dim hWnd As Long
Dim lngStyle As Long
Dim lpdwProcessID As Long
hWnd = apiGetWindow(apiGetDesktopWindow, GW_CHILD)
Do While hWnd
lngStyle = apiGetWindowLong(hWnd, GWL_STYLE)
If (lngStyle And WS_VISIBLE) Then
If StrComp(strClassName, fGetClassName(hWnd)) = 0 Then
Call apiGetWindowThreadProcessId(hWnd, lpdwProcessID)
fGetProcessID = lpdwProcessID
Exit Function
End If
End If
hWnd = apiGetWindow(hWnd, GW_HWNDNEXT)
Loop
End Function
Private Function fGetClassName(hWnd As Long)
Dim strBuffer As String
Dim lngCount As Long
strBuffer = String$(MAX_LEN - 1, 0)
lngCount = apiGetClassName(hWnd, strBuffer, MAX_LEN)
If lngCount > 0 Then
fGetClassName = Left$(strBuffer, lngCount)
End If
End Function
'************** Code End ***************
-- Dev
DHI <jeppe_klingberg_x@bigfoot.com> wrote in message
news:MPG.1200ed9fd827fcb8989681@news.dhi.dk...
: Hi Folks,
:
: Well, it may be a bit off-topic but I need a function in my Access
: App. (properly a MFD-function) which returns the process-ID for a given
: task as shown in the Task Manager.
:
: Thanx in advance..
:
: Regards Jeppe
Re: Get ProcessID for given task
Author: jeppe_klingberg
Date: Fri, 23 Jul 1999 00:00
Date: Fri, 23 Jul 1999 00:00
17 lines
1176 bytes
1176 bytes
Hi Dev, Thanx for your code, it was right in the eye! Regards Jeppe In article <7n80iq$lob$1@bgtnsc02.worldnet.att.net>, "Dev Ashish" <dash10@hotmail.com> wrote: > Hi Jeppe, > > Try something like this if you know the class name of theapp you're > looking for. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads