Article ID: 104710
Article Last Modified on 5/6/2003
'**************************************************************
' MODULE DECLARATION SECTION
'**************************************************************
Option Compare Database 'Use database order for string comparisons
Option Explicit
'Windows API Declarations
Declare Function alias_ShowWindow Lib "User" Alias "ShowWindow" _
(ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
Declare Function alias_FindWindow Lib "user" Alias "FindWindow" _
(ByVal lpclassname As String, ByVal lpCaption As Any) As Integer
Declare Function alias_SetActiveWindow Lib "User" Alias _
"SetActiveWindow" (ByVal hWnd As Integer) As Integer
Const SW_SHOW = 9
'******************************************************************
' FUNCTION: AppActivateClass()
'
' PURPOSE: Used to activate another application by using its
' class name instead of the title bar text as AppActivate does.
'
' ARGUMENTS:
' lpClassName$ - The Class Name of the application.
'
' RETURNS:
' 0 - The application was not found - it either was not running
' or the class name is incorrect
' -1 - The application was activated
'******************************************************************
Function AppActivateClass(lpclassname$)
Dim hWnd As integer 'the application's window handle
Dim dummy as integer 'Dummy variable
'Get the Window Handle
hWnd = alias_FindWindow(lpclassname$, 0&)
'Activate the Application
dummy = alias_SetActiveWindow(hWnd)
dummy = alias_ShowWindow(hWnd, SW_SHOW)
'Return True if Application Running, or False if not.
AppActivateClass = hWnd
End Function
x=AppActivateClass("opusapp")
Class Name Application ---------------------------------------- OMain ACCESS.EXE SciCalc CALC.EXE CalWndMain CALENDAR.EXE Cardfile CARDFILE.EXE Clipboard CLIPBOARD.EXE Clock CLOCK.EXE CtlPanelClass CONTROL.EXE XLMain EXCEL.EXE Session MS-DOS.EXE Notepad NOTEPAD.EXE pbParent PBRUSH.EXE Pif PIFEDIT.EXE PrintManager PRINTMAN.EXE Progman PROGMAN.EXE (Windows Program Manager) Recorder RECORDER.EXE Reversi REVERSI.EXE #32770 SETUP.EXE Solitaire SOL.EXE Terminal TERMINAL.EXE WFS_Frame WINFILE.EXE MW_WINHELP WINHELP.EXE #32770 WINVER.EXE OpusApp WINWORD.EXE MSWRITE_MENU WRITE.EXE
Class Name Application ---------------------------------------------------- CabinetWClass My Computer Window Internet Explorer_Frame IEXPLORE.EXE MSPaintApp MSPAINT.EXE SageWindowClass System Agent Com Window Shell_Traywnd Windows 95 Task Bar WordPadClass WORDPAD.EXE DialerClass DIALER.EXE SJE_CDPlayerClass CDPLAYER.EXE MyDlgClass CHARMAP.EXE MSDefragWClass1 DEFRAG.EXE GFVMainWndClass FAXVIEW.EXE FreeWClass FREECELL.EXE Mplayer MPLAYER.EXE AfxFrameorView HEARTS.EXE NW_Class NETWATCH.EXE AppClass PACKAGER.EXE System Policy Editor POLEDIT.EXE PWLEdit PWLEDIT.EXE RegEdit_RegEdit REGEDIT.EXE ScanDskWDlgClass SCANDSK.EXE SoundRec SNDREC32.EXE Volume Control SNDVOL32.EXE System Monitor SYSMON.EXE MSTaskSwWClass TASKMAN.EXE TelnetWClass TELNET.EXE WinIPCfgClass WINIPCFG.EXE WordPadClass WORDPAD.EXE Session_Window HYPERTRM.EXE
Additional query words: caption
Keywords: kbhowto kbprogramming KB104710