CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2006
    Posts
    326

    [RESOLVED] "Unable to find an entry point named 'GetForegroundwindow' in DLL 'User32.dll'."

    Hello,

    I don't know why I got the error.
    Code:
    EntryPointNotFoundException was unhandled by user code
    Thanks for help.
    Code:
    Private Declare Function SetForegroundwindow Lib "User32" (ByVal hwnd As IntPtr) As IntPtr
        Private Declare Function GetForegroundwindow Lib "User32.dll" () As IntPtr
        Private Declare Function SetActiveWindow Lib "user32" Alias "SetActiveWindow" (ByVal hwnd As Long) As Long
        Private Declare Function GetActiveWindow Lib "user32" Alias "GetActiveWindow" () As Long
    Public Overrides Function Execute(ByVal xmlInput As System.Xml.XmlElement, ByVal oInputValues As System.Collections.IDictionary) As System.Xml.XmlElement
    ' ....
    
    Dim handler As IntPtr
            handler = GetForegroundWindow() ' Error here
            SetActiveWindow(handler)

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: "Unable to find an entry point named 'GetForegroundwindow' in DLL 'User32.dll'."

    Don't know where you got your declarations, but all of them should be Int32, and not IntPtr :

    Code:
    Private Declare Function GetForegroundWindow Lib "user32.dll" () As Int32
    Private Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Int32) As Int32
    Private Declare Function SetActiveWindow Lib "user32.dll" (ByVal hwnd As Int32) As Int32
    Private Declare Function GetActiveWindow Lib "user32.dll" () As Int32
    I'd suggest you get a copy of API Viewer 2004

    Also, APIs are case sensitive, as they originate from C / C++ - so that may also cause a problem

  3. #3
    Join Date
    Jan 2006
    Posts
    326

    Re: "Unable to find an entry point named 'GetForegroundwindow' in DLL 'User32.dll'."

    Here used Intptr.
    http://www.pinvoke.net/default.aspx/...etactivewindow
    Which one is right?

  4. #4
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Arrow Re: "Unable to find an entry point named 'GetForegroundwindow' in DLL 'User32.dll'."

    Like Hannes said, entry point names are case sensitive. That is your only issue.
    Code:
    Private Declare Function GetForegroundWindow Lib "User32.dll" () As IntPtr
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: [RESOLVED] "Unable to find an entry point named 'GetForegroundwindow' in DLL 'Use

    Yep, it seems I was smoking something that affected my braincells today. IntPtr is correct, Ddh! Hannes!

    Sorry zhshqzyc - I'm just human afterall LOL!

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

Featured