Question

Showing all tasks, and being able to close/kill them, or set focus to them

Asked by: ThaSmartUno

For instance, Conseal firewall the desktop version shows you all the programs that are running that are using a port.  I would like my program to show all the programs running, even if they are running as services.

Thanks, your help is appreciated.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2000-02-23 at 14:27:28ID10300064
Topic

Visual Basic Programming

Participating Experts
2
Points
150
Comments
30

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Database, service, instance and PORT
    Whenever I installed oracle 8.1.6 enterprise servcer on winNT, I was asked for GDN and SID. This SID is treated as service, database and instance name. Can we not have different names for each of the three while/after installation. Can we have more than one instance of the sa...
  2. Kill a process
    I need to kill a process (actually a 'service') programmatically using VB6. This process has no forms or windows (it is a service running in the background). All the examples I can find to kill a process involve using 'GetWindow()' to find the hWnd handle by window caption...
  3. how to kill the port running in the machine
    when i run application server i am getting port is already running is coming;when i run this command netstat -an that port is running inside on host 127.0.0.1;how to kill the post
  4. how to kill ports which is already running
    how to kill ports which is already running;before killing i want to see what ports are running inside??
  5. Remote Desktop Connection and TCP/UDP Ports
    Hello, I'm currently running a service (QuickBooks Remote Data Sharing Server) that uses UDP/TCP Port 3790. Whenever a Remote Desktop Connection logs into the machine running this service it kills the service, and then the service needs to be restarted. My guess is that RDC i...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: RuchiPosted on 2000-02-23 at 14:54:21ID: 2552445

download:

kpd-team.hypermart.net/download/tasks.zip

i think this is what you are looking for??

 

by: ThaSmartUnoPosted on 2000-02-23 at 15:02:17ID: 2552477

its what im looking for ... but it has too much crap .  For instance there is about 10 of "DDE Server Window" and the same with OleMainThreadWndName, so is there an ez way to get rid of these, without getting rid of a real program?

 

by: MaquiaveloPosted on 2000-02-23 at 19:21:41ID: 2553062

 See www.thescarms.com, there's a sample with source code that list all proccesses running (it's for WIN9x), if you need NT code let me know (I can't access now because I'm on a different partition... ;))

 

by: ThaSmartUnoPosted on 2000-02-23 at 20:59:52ID: 2553221

I went there and I downloaded 3 files, 1 of them worked, the other 2 gave me errors.  I downloaded Running processes, how to safely kill a process, and how to check if something was not responding.  The first one worked and other 2 were errors.

Could you provide some source code, that will work?

Thanks

 

by: ThaSmartUnoPosted on 2000-02-23 at 22:20:19ID: 2553324

So if i didn't make the question clear ... i wanted to know how to list em (accomplished) and how to set focus to them (not accomplished) and how to kill them (not accomplished)

Thanks

 

by: ThaSmartUnoPosted on 2000-02-23 at 23:28:16ID: 2553466

well i found how to terminate the application, at planet-source-code.com ... but i still need to know how to set focus to an app ...

 

by: MaquiaveloPosted on 2000-02-24 at 18:49:10ID: 2556446

 This VBP has a form and a BAS. In the form you have 3 buttons and a listbox.

  Cut & paste this. It should work. I did it and test it myself.

VERSION 5.00
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   5145
   ClientLeft      =   1650
   ClientTop       =   1650
   ClientWidth     =   7200
   LinkTopic       =   "Form1"
   ScaleHeight     =   5145
   ScaleWidth      =   7200
   Begin VB.CommandButton Command3
      Caption         =   "Set Focus"
      Height          =   495
      Left            =   2400
      TabIndex        =   3
      Top             =   4440
      Width           =   1695
   End
   Begin VB.CommandButton Command2
      Caption         =   "Close"
      Height          =   495
      Left            =   4560
      TabIndex        =   2
      Top             =   4440
      Width           =   1815
   End
   Begin VB.ListBox lstApp
      Height          =   3960
      Left            =   480
      TabIndex        =   1
      Top             =   240
      Width           =   5895
   End
   Begin VB.CommandButton Command1
      Caption         =   "Show running apps"
      Height          =   495
      Left            =   480
      TabIndex        =   0
      Top             =   4440
      Width           =   1455
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
    Dim hWnd& 'The same that 'As Long'
    Dim cWinTextLength As String
    Dim cWinText As String * 255
   
    ' Clear the listbox
    lstApp.Clear

    ' The desktop is the highest window
    hWnd& = GetDesktopWindow()

    ' It's first child is the 1st top level window
    hWnd& = GetWindow(hWnd&, GW_CHILD)

    ' Now load all top level windows
    Do
        cWinTextLength = GetWindowText(hWnd&, cWinText, 255)
        If cWinTextLength > 0 Then
            lstApp.AddItem Left(cWinText, cWinTextLength)
            lstApp.ItemData(lstApp.NewIndex) = hWnd&
        End If
        hWnd& = GetWindow(hWnd&, GW_HWNDNEXT)
    Loop While hWnd& <> 0
End Sub


Private Sub Command2_Click()
    If lstApp.ListIndex > -1 Then
        Call SendMessage(lstApp.ItemData(lstApp.ListIndex), WM_CLOSE, 0, 0)
    End If
End Sub

Private Sub Command3_Click()
    Dim hWnd As Long ' handle to window
    Dim x As Long ' work area
    Dim lngWW As Long ' Window Style bits
   
    If lstApp.ListIndex < 0 Then Beep: Exit Sub
   
    ' Get window handle from listbox array
    hWnd = lstApp.ItemData(lstApp.ListIndex)
   
    ' Get style bits for window
    lngWW = GetWindowLong(hWnd, GWL_STYLE)
   
    ' If minimized do a restore
    If lngWW And WS_MINIMIZE Then
    x = ShowWindow(hWnd, SW_RESTORE)
    End If
   
    ' Move window to top of z-order/activate; no move/resize
    x = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW)
End Sub

This is the bas module:

Attribute VB_Name = "Module1"
Option Explicit

Public Const WM_CLOSE = &H10

Public Const GW_HWNDNEXT = 2
Public Const GW_CHILD = 5

Public Const GWL_STYLE = (-16)

Public Const SW_RESTORE = 9

Public Const WS_MINIMIZE = &H20000000

Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_SHOWWINDOW = &H40

Public Const HWND_TOP = 0


Public Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal wIndx As Long) As Long
Public Declare Function GetDesktopWindow Lib "User32" () As Long
Public Declare Function GetWindow Lib "User32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Public Declare Function GetWindowText Lib "User32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function ShowWindow Lib "User32" (ByVal hWnd As Long, ByVal flgs As Long) As Long
Public Declare Function SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal insaft As Long, ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, ByVal flgs As Long) As Long

'This functions sends a msg
Public Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long


 

by: ThaSmartUnoPosted on 2000-02-24 at 23:06:57ID: 2556923

this has the kill statement, but its just like the link thar Ruchi gave.

There is multiple items of the same program, and there are many different items called "DDE Server Window" and "OleMainThreadWndName"

so is there a way to take all the duplicates out and all the extra crap? ... thanks

 

by: RuchiPosted on 2000-02-25 at 08:28:25ID: 2558607

 

by: ThaSmartUnoPosted on 2000-02-25 at 19:16:37ID: 2560214

can i spilt the points? ... meaning make 2 more questions, making one names "Points for Ruchi" and "Points for Maquiavelo"  with 75 pts a piece? ... cuz u both helped and thanks

 

by: MaquiaveloPosted on 2000-02-25 at 19:29:01ID: 2560222

Try this one now... shows no crap...

VERSION 5.00
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   5145
   ClientLeft      =   1650
   ClientTop       =   1650
   ClientWidth     =   7200
   LinkTopic       =   "Form1"
   ScaleHeight     =   5145
   ScaleWidth      =   7200
   Begin VB.CommandButton cmdSetFocus
      Caption         =   "Set Focus"
      Height          =   495
      Left            =   2400
      TabIndex        =   3
      Top             =   4440
      Width           =   1695
   End
   Begin VB.CommandButton cmdClose
      Caption         =   "Close"
      Height          =   495
      Left            =   4560
      TabIndex        =   2
      Top             =   4440
      Width           =   1815
   End
   Begin VB.ListBox lstApp
      Height          =   3960
      Left            =   480
      TabIndex        =   1
      Top             =   240
      Width           =   5895
   End
   Begin VB.CommandButton cmdShowRunningApps
      Caption         =   "Show running apps"
      Height          =   495
      Left            =   480
      TabIndex        =   0
      Top             =   4440
      Width           =   1455
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdShowRunningApps_Click()
    Dim hwnd&
    Dim res&
    Dim Iconic&
    Dim cWinTextLength As String
    Dim cWinText As String * 255
   
    ' Clear the listbox
    lstApp.Clear

    ' The desktop is the highest window
    hwnd& = GetDesktopWindow()

    ' It's first child is the 1st top level window
    hwnd& = GetWindow(hwnd&, GW_CHILD)

    ' Now load all top level windows
    Do
        cWinTextLength = GetWindowText(hwnd&, cWinText, 255)
        If cWinTextLength > 0 Then
            res& = IsWindowVisible(hwnd&) 'Check if window is visible
            Iconic& = IsIconic(hwnd&) 'Check if window is an icon in the systray
            If Iconic& = 0 Then
                If res& <> 0 Then
                    res& = GetWindow(hwnd&, GW_OWNER) 'Check if the window has an owner (this prevents more than one window for each app)
                    If res& = 0 Then
                        lstApp.AddItem Left(cWinText, cWinTextLength)
                        lstApp.ItemData(lstApp.NewIndex) = hwnd&
                    End If
                End If
            Else
                lstApp.AddItem Left(cWinText, cWinTextLength)
                lstApp.ItemData(lstApp.NewIndex) = hwnd&
            End If
        End If
        hwnd& = GetWindow(hwnd&, GW_HWNDNEXT)
    Loop While hwnd& <> 0
End Sub


Private Sub cmdClose_Click()
    If lstApp.ListIndex > -1 Then
        Call SendMessage(lstApp.ItemData(lstApp.ListIndex), WM_CLOSE, 0, 0)
    End If
End Sub

Private Sub cmdSetFocus_Click()
    Dim hwnd As Long ' handle to window
    Dim x As Long ' work area
    Dim lngWW As Long ' Window Style bits
   
    If lstApp.ListIndex < 0 Then Beep: Exit Sub
   
    ' Get window handle from listbox array
    hwnd = lstApp.ItemData(lstApp.ListIndex)
   
    ' Get style bits for window
    lngWW = GetWindowLong(hwnd, GWL_STYLE)
   
    ' If minimized do a restore
    If lngWW And WS_MINIMIZE Then
    x = ShowWindow(hwnd, SW_RESTORE)
    End If
   
    ' Move window to top of z-order/activate; no move/resize
    x = SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW)
End Sub

-----------------------------------------------------------------
This is the BAS code:

Attribute VB_Name = "Module1"
Option Explicit

Public Const WM_ACTIVATE = &H6
Public Const WM_CLOSE = &H10

Public Const GW_HWNDNEXT = 2
Public Const GW_CHILD = 5
Public Const GW_OWNER = 4

Public Const GWL_STYLE = (-16)

Public Const SW_RESTORE = 9
Public Const SW_HIDE = 0

Public Const WS_MINIMIZE = &H20000000

Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_SHOWWINDOW = &H40

Public Const HWND_TOP = 0

Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal wIndx As Long) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal flgs As Long) As Long
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal insaft As Long, ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, ByVal flgs As Long) As Long
Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long

'This functions sends a msg
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

 

by: ThaSmartUnoPosted on 2000-02-25 at 19:55:00ID: 2560262

actually ... i have one question ... could one of you make a function call SetAppFocus  that will Set Focus to the App, like the one Maquiavelo did ... but without using a list, only using the text sent with the function,

for ex. something = SetAppFocus("x:\windows\notepad.exe")

and it would setfocus to notepad ... thanks

 

by: ThaSmartUnoPosted on 2000-02-25 at 19:58:25ID: 2560268

Your close doesn't work.

 

by: ThaSmartUnoPosted on 2000-02-25 at 19:59:27ID: 2560270

no wait it works

 

by: MaquiaveloPosted on 2000-02-26 at 09:01:51ID: 2561145

 Regarding the following:

actually ... i have one question ... could one of you make a function call SetAppFocus  that will Set Focus to the App, like the one Maquiavelo did ... but without using a list, only using the text sent with the function,

for ex. something = SetAppFocus("x:\windows\notepad.exe")

and it would setfocus to notepad ... thanks

  even thoug it would be another question, wich means more points :),

you can iterate through the running processes till you find the one you're looking for (i.e.: notepad.exe), (you can do this with the sample from thescarms.com), once there find the associated window handle to that process and finally use the SendMessage function with that handle.

 

by: ThaSmartUnoPosted on 2000-02-26 at 09:58:56ID: 2561237

why would this be another question? ... this is part of my total question...

Title: "Showing all tasks, and being able to close/kill them, or set focus to them"

and I can't get your code into a function because it heavily depends on the list

 

by: ThaSmartUnoPosted on 2000-02-26 at 22:30:01ID: 2562103

Actually it was the answer before this ... the one "without the crap" =) thanks, I figured out a way to incorporate it into my program.  If you want to do the function you can.  But you don't have to.

And Ruchi thanks, but he provided the code to everything.


Thanks again to both of ya.

 

by: MaquiaveloPosted on 2000-02-27 at 11:32:52ID: 2562862

 What function you mean? The notepad.exe example?

 

by: ThaSmartUnoPosted on 2000-02-27 at 12:42:02ID: 2562959

something = SetAppFocus("x:\windows\notepad.exe")


that one

 

by: MaquiaveloPosted on 2000-02-27 at 14:47:45ID: 2563206

 Ok. Let me work on it. ;)

 

by: MaquiaveloPosted on 2000-02-27 at 17:18:44ID: 2563455

 OK here it is.

You should add this code to the previous sample I sent you, because
there are there some declarations U still need. For this to work
U have to enter the whole path i.e.: c:\windows\notepad.exe. U can solve
this where I put the *.

Public Sub SetFocusApp()
    Dim IBox As String
    Dim lSnapShot  As Long
    Dim r          As Long
    Dim uProcess   As PROCESSENTRY32
    Dim hWnd As Long
   
    IBox = InputBox("")
    If Len(Trim(IBox)) > 0 Then
        lSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
        If lSnapShot <> 0 Then
            uProcess.lSize = Len(uProcess)
            r = ProcessFirst(lSnapShot, uProcess)
            Do While r
            '*: Here you can manipulate strings so that work without the whole path
                If Trim(UCase(IBox)) = Left(uProcess.sExeFile, InStr(1, uProcess.sExeFile, vbNullChar) - 1) Then
                    'Now look 4 the window that has this PID
                    hWnd = FindWin(uProcess.lProcessId)
                    'If found show it
                    If hWnd > 0 Then Call ShowWindow(hWnd, SW_RESTORE)
                End If
                'sParentPid = Hex$(uProcess.lParentProcessId)
                r = ProcessNext(lSnapShot, uProcess)
            Loop
            CloseHandle (lSnapShot)
        End If
    End If
End Sub

This goes to the BAS

Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Public Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Public Declare Function EnumThreadWindows Lib "user32" (ByVal dwThreadId As Long, ByVal lpfn As Long, ByVal lParam As Long) As Long
Public Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long


'-------------
Public Const MAX_PATH = 260
Public Const TH32CS_SNAPPROCESS = 2&

Public Type PROCESSENTRY32
    lSize            As Long
    lUsage           As Long
    lProcessId       As Long
    lDefaultHeapId   As Long
    lModuleId        As Long
    lThreads         As Long
    lParentProcessId As Long
    lPriClassBase    As Long
    lFlags           As Long
    sExeFile         As String * MAX_PATH
End Type

Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessId As Long) As Long
Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long

 

by: MaquiaveloPosted on 2000-02-27 at 17:21:25ID: 2563461

 Sorry forget the FindWin function.

Private Function FindWin(PID As Long) As Long
    Dim hWnd&
    Dim res&
    Dim hProc&
   
    ' The desktop is the highest window
    hWnd& = GetDesktopWindow()

    ' It's first child is the 1st top level window
    hWnd& = GetWindow(hWnd&, GW_CHILD)

    ' Now load all top level windows
    Do
        res& = GetWindowThreadProcessId(hWnd&, hProc&)
        If res& <> 0 Then
            If hProc& = PID Then
                FindWin = hWnd&
                Exit Function
            End If
        End If
        hWnd& = GetWindow(hWnd&, GW_HWNDNEXT)
    Loop While hWnd& <> 0
End Function

 

by: RuchiPosted on 2000-02-27 at 22:40:14ID: 2563861

No problem, thasmartuno!
Did you get it working?

 

by: ThaSmartUnoPosted on 2000-02-28 at 12:40:34ID: 2566390

Well thanks for trying the function, but it didn't work.  That's ok though.

I got it working using the list.

 

by: MaquiaveloPosted on 2000-02-28 at 16:03:07ID: 2566951

 Weird... it did work on my PC! What err did U get?

 

by: ThaSmartUnoPosted on 2000-02-28 at 16:19:20ID: 2566988

nothing happened ... i called the function ... and nothing happened.

 

by: MaquiaveloPosted on 2000-03-01 at 18:01:22ID: 2574987

 Sorry for asking this, but wich function did you call?

  You have to do sth like this:

call SetAppFocus()

  I can't believe it does not show a thing! At least should show the InputBox dialog!!

Note: the app has to be running for the function to work.

 

by: ThaSmartUnoPosted on 2000-03-01 at 19:57:50ID: 2575173

the input box shows ... and i ran notepad.exe ... and i put in the input box "C:\windows\notepad.exe"

without quotes ...

 

by: MaquiaveloPosted on 2000-03-02 at 17:58:01ID: 2578658

 And...

1) you have the notepad window minimized
2) this minimized window does not restore??

 

by: ThaSmartUnoPosted on 2000-03-03 at 16:59:12ID: 2582176

not minimized just not focused

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...