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. C / C++ / MFC
  4. LoadString

LoadString

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
3 Posts 3 Posters 1 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.
  • M Offline
    M Offline
    Member_14502583
    wrote on last edited by
    #1

    how to use LoadString in c++

    D L 2 Replies Last reply
    0
    • M Member_14502583

      how to use LoadString in c++

      D Offline
      D Offline
      Daniel Pfeffer
      wrote on last edited by
      #2

      The Windows API LoadString() expects a buffer, not a C++ string. The easiest way to use it would be something like:

      std::wstring GetStringW(HINSTANCE hinst, UINT id)
      {
      std::vector buffer(256);

      ::LoadStringW(hinst, id, buffer.data(), static\_cast(buffer.size()));
      return &buffer\[0\];
      

      }

      which would convert the buffer into a std::wstring.

      Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

      1 Reply Last reply
      0
      • M Member_14502583

        how to use LoadString in c++

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Start by checking the documentation: LoadStringA function (winuser.h) - Win32 apps | Microsoft Docs[^]

        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