Results 1 to 3 of 3

Thread: Using FindWindow in VB.Net!??!

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    San Marino, CA, USA
    Posts
    2

    Question Using FindWindow in VB.Net!??!

    Problem is . . . I use this code in VB 6.0 and everything works peachy . . . when I enter it into VB .Net it compiles errorless but doesn't work . . . the FindWindow returns something like "325609862626246" instead of a smaller, more expected window handle . . . any help!? what's different with .Net . . . i bet it's something really easy!! thanks for any help . . . here's my code to find the title of Winamp:

    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long

    Dim lngHWND As Long, lngLen As Long
    Dim strCurrentSong As String

    lngHWND = FindWindow("Winamp v1.x", vbNullString)
    lngLen = GetWindowTextLength(lngHWND)
    strCurrentSong = Space(lngLen)
    Call GetWindowText(lngHWND, strCurrentSong, (lngLen + 1))
    MsgBox(strCurrentSong)
    D I G I F R E E
    http://66.74.248.19/

  2. #2
    Member
    Join Date
    May 2002
    Location
    Malaysia
    Posts
    45
    I am not sure wheter this going help or not... data type in vb.net is quite different from vb6. for example long in vb6 is become the integer type in vb.net. Therefore for any declaration long data type in the API in VB6 should change to integer type.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    San Marino, CA, USA
    Posts
    2

    Lightbulb why . . . why . . .

    ok . . . problem solved i guess . . . i did what you said and replaced every "Long" with "Integer" in declarations and program and it works . . . I swear I read like 10 "What's different from VB6 to VB.Net" articles and not ONE mentioned this change once . . . thanks so much though
    D I G I F R E E
    http://66.74.248.19/

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