Results 1 to 6 of 6

Thread: api call to return handle of another app?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Location
    Phoenix
    Posts
    87
    i would like to get the handle from Oracle's SQL*Plus application. I'd like to send data to it for automation purposes.

    Is there a way to get a handle by cycling through the open applications til i find one with a form caption of 'Oracle SQL*Plus'?

    thanks

  2. #2
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752

    I hope This is what u need

    U can use Findwindow or FindwindowEx API call
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  3. #3
    Guest
    Example

    Code:
    Private Declare Function FindWindow Lib "user32" _
     Alias "FindWindowA" (ByVal lpClassName As String, ByVal _
    lpWindowName As String) As Long
    
    Private Sub Command1_Click()
    
        hWin = FindWindow(Class, Caption)
        If hWin <> 0 Then
            MsgBox "Window found: " & hWin
        Else
            MsgBox "Window not found: " & hWin 
            'hWin = 0
        End If
    
    End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Location
    Phoenix
    Posts
    87

    tried that!

    i'm using the following.. taken mostly from the WinNT Win32 API bible...

    for example.. start up the windows clock (clock.exe).. try to return the handle of the window by searching for a window with 'Clock' as the title (as per the book example)

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

    Private Sub Command1_Click()
    Dim i As Long

    i = FindWindow(vbNull, "Clock")

    'show me the @#$% handle!
    MsgBox Str(i)

    'always returns 0 =(
    End Sub


  5. #5
    Guest
    First off, use FindWindowEx instead of FindWindow (it's an updated version).
    Secondly, Use vbNullString instead of vbNull.
    Thirdly, I think you are referring to "date/time properties" instead of clock.

    Add the following to a Form with a CommandButton.
    Code:
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    
    Private Sub Command1_Click()
        Dim hApp As Long
        
        hApp = FindWindowEx(0, 0, vbNullString, "Date/Time Properties")
        If hApp <> 0 Then MsgBox "Clock is open"
    End Sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Location
    Phoenix
    Posts
    87
    thanks everyone!

    findwindowex is working great now.

    megatron: i actually *was* using clock.exe (not date/time properties) its that crusty old clock thats been carried over from the win3.x days. I know its included with nt4.. not sure about win98 and after.. anyway.. no matter.. thanks for your help

    have a good turkey day

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width