Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

API (VB6) for Closing a tray icon program

Posted on 2004-10-19
4
Medium Priority
?
312 Views
Last Modified: 2012-08-14
My data provider recently changed their program from a "Windowed application" to just a system tray program.  I used to close the GUI program like this:

   lngWin = FindWindow(vbNullString, "TALNET")
   If lngWin <> 0 Then SendMessage lngWin, WM_CLOSE, 0&, 0&

But that doesn't work anymore because there is no window.  My provider emailed back:

"Using the Win32 SendMessage API was a good idea for an app that had a GUI window, as TALNET did.  Since TALDDE's just a tray icon, the logical analogy would be to find the Win32 API for sending a message to a tray icon"

Can anyone send me the code to close a program that is only running in the system tray?  The program is called "taldde32.exe" in the Processes tab of the Windows Task Manager.

 




0
Comment
Question by:LovinSpoonful
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 2000 total points
ID: 12349698
This can be done using WMI as follows:

Dim oProcess

For Each oProcess In GetObject("winmgmts:root\cimv2").ExecQuery("Select * from " & _
                    "Win32_Process Where Name = 'taldde32.exe'")

    oProcess.Terminate
    Debug.Print oProcess.Name & " was terminated..."

Next
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 12349709
Try to find the process using API
Declare Function EnumProcesses Lib "PSAPI.DLL" (ByRef lpidProcess As Long, _
                                                                        ByVal cb As Long, _
                                                                        ByRef cbNeeded As Long) As Long


Then use

Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Long, _
                                                                                                               ByVal uExitCode As Long) As Long

to terminate the process
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 12349782
I agree with Erick37
Nice solution!
0
 

Author Comment

by:LovinSpoonful
ID: 12369592
thank you Erick37.  
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question