Solved

Closing a program with only the task name

Posted on 1998-09-29
3
175 Views
Last Modified: 2010-04-30
How do you force a program to close by only using the name of the program when hitting Ctrl+Alt+Del?
0
Comment
Question by:Evil_Sorcerer
3 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 1437270
I'm not sure what you're after here. If you press <CTRL/ALT/DEL> you can select the program by pressing the first letter of the program.
0
 

Author Comment

by:Evil_Sorcerer
ID: 1437271
Excuse me, maybe I didn't state the answer clearly, how to close it using the name with API
0
 
LVL 2

Accepted Solution

by:
shchuka earned 40 total points
ID: 1437272
You can use FindWindow() API and then CloseWindow() api:

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Declare Function CloseWindow Lib "user32" Alias "CloseWindow" (ByVal hwnd As Long) As Long

FindWindow needs window class name.  If you don't know what the class name is (it might depend on what language the program was written in), then you can use GetNextWindow() and GetWindowText() to iterate through open window until you find the one you need.  Once you get the hWnd of the window, simply issue

Call CloseWindow(hWnd) to terminate that application.

Hope this helps,
-Aleks.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now