Results 1 to 2 of 2

Thread: ShellAndFind

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    ShellAndFind

    This is for finding a programs hwnd immediately after shelling, for use if you need to hide it or something

    VB Code:
    1. Option Explicit
    2. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    3.     ByVal lpClassName As String, _
    4.     ByVal lpWindowName As String _
    5. ) As Long
    6.  
    7. Private Declare Function GetParent Lib "user32" ( _
    8.     ByVal hwnd As Long _
    9. ) As Long
    10.  
    11. Private Declare Function GetWindowThreadProcessId Lib "user32" ( _
    12.    ByVal hwnd As Long, _
    13.    lpdwProcessId As Long _
    14. ) As Long
    15. Private Declare Function GetWindow Lib "user32.dll" ( _
    16.     ByVal hwnd As Long, _
    17.     ByVal wCmd As Long _
    18. ) As Long
    19.  
    20. Private Const GW_HWNDNEXT As Long = 2
    21.  
    22. Private Sub Form_Load()
    23. MsgBox ShellAndFind("C:\Documents and Settings\Jason\Desktop\project1.exe")
    24. End Sub
    25.  
    26. Private Function ShellAndFind(Path As String) As Long
    27. Dim testHWND As Long
    28. Dim testPID As Long
    29. Dim testID As Long
    30. Path = Shell(Path)
    31.     testHWND = FindWindow(vbNullString, vbNullString)
    32.  
    33.     Do While testHWND <> 0
    34.         If GetParent(testHWND) = 0 Then
    35.             testID = GetWindowThreadProcessId(testHWND, testPID)
    36.             If testPID = Path Then
    37.                 ShellAndFind = testHWND
    38.                 Exit Do
    39.             End If
    40.         End If
    41.  
    42.         testHWND = GetWindow(testHWND, GW_HWNDNEXT)
    43.     Loop
    44. End Function
    45. 'NOTE:I modified code from another site to suit my needs, it isnt exact, or close to it for that matter.

    I got some code from another site..tell me if you like it
    Last edited by |2eM!x; Oct 24th, 2005 at 02:36 PM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: ShellAndFind

    Quote Originally Posted by |2eM!x
    I got some code from another site..tell me if you like it
    From what site did you get this code? Please give me a link.

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