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. Casting problem (String* to LPCVOID)

Casting problem (String* to LPCVOID)

Scheduled Pinned Locked Moved Managed C++/CLI
helptutorialquestion
4 Posts 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hello... I have a function called:

    MyFunction(LPCVOID lpBuffer)
    {
    //... do something...
    }

    But my parameter is a String*, for example:

    String* s = "Hello World";

    Are there any possibilities to cast String* to LPCVOID ?

    T N M 3 Replies Last reply
    0
    • L Lost User

      Hello... I have a function called:

      MyFunction(LPCVOID lpBuffer)
      {
      //... do something...
      }

      But my parameter is a String*, for example:

      String* s = "Hello World";

      Are there any possibilities to cast String* to LPCVOID ?

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      i'd like to know one thing though : where is defined the type LPCVOID ? isn't it an MFC type ?


      TOXCCT >>> GEII power

      [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

      1 Reply Last reply
      0
      • L Lost User

        Hello... I have a function called:

        MyFunction(LPCVOID lpBuffer)
        {
        //... do something...
        }

        But my parameter is a String*, for example:

        String* s = "Hello World";

        Are there any possibilities to cast String* to LPCVOID ?

        N Offline
        N Offline
        NrmMyth
        wrote on last edited by
        #3

        See System::Runtime::InteropServices::Marshal class.

        1 Reply Last reply
        0
        • L Lost User

          Hello... I have a function called:

          MyFunction(LPCVOID lpBuffer)
          {
          //... do something...
          }

          But my parameter is a String*, for example:

          String* s = "Hello World";

          Are there any possibilities to cast String* to LPCVOID ?

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          You can't do a plain cast from a managed pointer to an unmanged one, you need to pin the managed pointer so the underlying object doesn't move during GCs.

          --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

          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