Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Reference User32.lib

Reference User32.lib

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++dotnetvisual-studiohelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thenutz72
    wrote on last edited by
    #1

    I'm trying to learn c++ and I just spent some time trying to use GetWindowText(). I was getting a linker error for unresolved token LNK2028, LNK2019. I finally added "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib\User32.lib" path to Project->Properties->Linker->Input and it worked. But I have two questions for anyone who may know so that I may understand a little better. And maybe someone else can use this later, too. .NET 2008 C++, WinXP Home 1) Why did I have to that? I kept telling myself the dll was already referenced and I had the "windows.h" #include going on. Everything looked correct (as far as my understanding goes (not far)). The code is in a normal CLR project, .NET Form button_click (so it must be using User32.dll already, right?). If you check the Linker->Input Additional Dependencies it shows User32.lib in "Inherited Values" along with all of the other Windows libraries. So I assumed I didn't have to add it. 2) It may have worked but did I do it 'right'? I ran a search on my drive for user32.lib (I expected it in C:\WINDOWS somewhere but it was in the path listed above. Should I move it? There are others in "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib" and the like. Thanks.

    M 1 Reply Last reply
    0
    • T thenutz72

      I'm trying to learn c++ and I just spent some time trying to use GetWindowText(). I was getting a linker error for unresolved token LNK2028, LNK2019. I finally added "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib\User32.lib" path to Project->Properties->Linker->Input and it worked. But I have two questions for anyone who may know so that I may understand a little better. And maybe someone else can use this later, too. .NET 2008 C++, WinXP Home 1) Why did I have to that? I kept telling myself the dll was already referenced and I had the "windows.h" #include going on. Everything looked correct (as far as my understanding goes (not far)). The code is in a normal CLR project, .NET Form button_click (so it must be using User32.dll already, right?). If you check the Linker->Input Additional Dependencies it shows User32.lib in "Inherited Values" along with all of the other Windows libraries. So I assumed I didn't have to add it. 2) It may have worked but did I do it 'right'? I ran a search on my drive for user32.lib (I expected it in C:\WINDOWS somewhere but it was in the path listed above. Should I move it? There are others in "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib" and the like. Thanks.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      thenutz72 wrote:

      Why did I have to that? I kept telling myself the dll was already referenced and I had the "windows.h" #include going on.

      windows.h has nothing to do with the linker. It's the import library you were missing that the linker needed.

      thenutz72 wrote:

      The code is in a normal CLR project, .NET Form button_click (so it must be using User32.dll already, right?).

      No. The .NET framework may use user32.dll internally but that has nothing to do with your project.

      thenutz72 wrote:

      It may have worked but did I do it 'right'?

      Not necessarily. If you're using native code from a managed class' code, the you would use platform invoke: Using Explicit PInvoke in C++ (DllImport Attribute)[^] You shouldn't be mixing paths to different SDKs. If you're using the Visual Studio IDE for your project, then use its directories settings to configure paths to the ONE SDK you want to use. Then you don't need paths in all your project configurations unless you need to override something. Learning C++/CLI is a pretty big undertaking for a beginner in C++... Are you sure you don't want to get familiar with the C++ language before adding the complexity of the managed world? All your questions are fundamentals you should know :)

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      T 1 Reply Last reply
      0
      • M Mark Salsbery

        thenutz72 wrote:

        Why did I have to that? I kept telling myself the dll was already referenced and I had the "windows.h" #include going on.

        windows.h has nothing to do with the linker. It's the import library you were missing that the linker needed.

        thenutz72 wrote:

        The code is in a normal CLR project, .NET Form button_click (so it must be using User32.dll already, right?).

        No. The .NET framework may use user32.dll internally but that has nothing to do with your project.

        thenutz72 wrote:

        It may have worked but did I do it 'right'?

        Not necessarily. If you're using native code from a managed class' code, the you would use platform invoke: Using Explicit PInvoke in C++ (DllImport Attribute)[^] You shouldn't be mixing paths to different SDKs. If you're using the Visual Studio IDE for your project, then use its directories settings to configure paths to the ONE SDK you want to use. Then you don't need paths in all your project configurations unless you need to override something. Learning C++/CLI is a pretty big undertaking for a beginner in C++... Are you sure you don't want to get familiar with the C++ language before adding the complexity of the managed world? All your questions are fundamentals you should know :)

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        T Offline
        T Offline
        thenutz72
        wrote on last edited by
        #3

        Awesome answer, thanks!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups