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. Shared Memory Writing

Shared Memory Writing

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresperformancehelp
7 Posts 6 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.
  • V Offline
    V Offline
    velayudhan_raj
    wrote on last edited by
    #1

    Hi Guys, A structure,which consists of member variables ( eg: int, float data type ) is written in a shared memory from a BackEnd application, which is accessed by a Front End application. When I try to write a Cstring variable or TCHAR array as member variable of the structure, it is not working, and exception occurs. Actually my need is to write a string to shared memory - from Back end, which is accessed by Front End. The string should be a member of this structure. So plz help me what datatype to be used. Thanks in Advance Velayudhan

    L V H J 4 Replies Last reply
    0
    • V velayudhan_raj

      Hi Guys, A structure,which consists of member variables ( eg: int, float data type ) is written in a shared memory from a BackEnd application, which is accessed by a Front End application. When I try to write a Cstring variable or TCHAR array as member variable of the structure, it is not working, and exception occurs. Actually my need is to write a string to shared memory - from Back end, which is accessed by Front End. The string should be a member of this structure. So plz help me what datatype to be used. Thanks in Advance Velayudhan

      L Offline
      L Offline
      Laxman Auti
      wrote on last edited by
      #2

      velayudhan_raj wrote:

      A structure,which consists of member variables ( eg: int, float data type ) is written in a shared memory from a BackEnd application, which is accessed by a Front End application. When I try to write a Cstring variable or TCHAR array as member variable of the structure, it is not working, and exception occurs. Actually my need is to write a string to shared memory - from Back end, which is accessed by Front End. The string should be a member of this structure. So plz help me what datatype to be used.

      Try Char* instead.:) Knock out 't' from can't, You can if you think you can :cool:

      V 1 Reply Last reply
      0
      • L Laxman Auti

        velayudhan_raj wrote:

        A structure,which consists of member variables ( eg: int, float data type ) is written in a shared memory from a BackEnd application, which is accessed by a Front End application. When I try to write a Cstring variable or TCHAR array as member variable of the structure, it is not working, and exception occurs. Actually my need is to write a string to shared memory - from Back end, which is accessed by Front End. The string should be a member of this structure. So plz help me what datatype to be used.

        Try Char* instead.:) Knock out 't' from can't, You can if you think you can :cool:

        V Offline
        V Offline
        velayudhan_raj
        wrote on last edited by
        #3

        Actually I am working in Unicode support application. so I tried with TCHAR* , but it is not working. A doubt : CString can't be written in Shared memory, as we cannot define the size of CString , Is it correct?

        T 1 Reply Last reply
        0
        • V velayudhan_raj

          Hi Guys, A structure,which consists of member variables ( eg: int, float data type ) is written in a shared memory from a BackEnd application, which is accessed by a Front End application. When I try to write a Cstring variable or TCHAR array as member variable of the structure, it is not working, and exception occurs. Actually my need is to write a string to shared memory - from Back end, which is accessed by Front End. The string should be a member of this structure. So plz help me what datatype to be used. Thanks in Advance Velayudhan

          V Offline
          V Offline
          Viorel
          wrote on last edited by
          #4

          A possible solution is to define a fixed-size array within your shared structure, for instance: TCHAR mName[100]. The size of the array must be large enough. Now for string-transfer operations use string-manipulation functions like strcpy in non-Unicode or wcscpy in Unicode mode. (If you use lstrcpy or StrCpy, then they will work in both modes). Unfortunately, this is problematic to use if you cannot predict and limit the largest size of your string.

          1 Reply Last reply
          0
          • V velayudhan_raj

            Hi Guys, A structure,which consists of member variables ( eg: int, float data type ) is written in a shared memory from a BackEnd application, which is accessed by a Front End application. When I try to write a Cstring variable or TCHAR array as member variable of the structure, it is not working, and exception occurs. Actually my need is to write a string to shared memory - from Back end, which is accessed by Front End. The string should be a member of this structure. So plz help me what datatype to be used. Thanks in Advance Velayudhan

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            See Here[^] maybe it is some helpful to you_**


            **_

            whitesky


            1 Reply Last reply
            0
            • V velayudhan_raj

              Actually I am working in Unicode support application. so I tried with TCHAR* , but it is not working. A doubt : CString can't be written in Shared memory, as we cannot define the size of CString , Is it correct?

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              velayudhan_raj wrote:

              Actually I am working in Unicode support application. so I tried with TCHAR* , but it is not working.

              Give Specfic Size to the String Member, i.e. USE TCHAR youObj[100];

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

              1 Reply Last reply
              0
              • V velayudhan_raj

                Hi Guys, A structure,which consists of member variables ( eg: int, float data type ) is written in a shared memory from a BackEnd application, which is accessed by a Front End application. When I try to write a Cstring variable or TCHAR array as member variable of the structure, it is not working, and exception occurs. Actually my need is to write a string to shared memory - from Back end, which is accessed by Front End. The string should be a member of this structure. So plz help me what datatype to be used. Thanks in Advance Velayudhan

                J Offline
                J Offline
                James R Twine
                wrote on last edited by
                #7

                If the two applications are complete separate processes, you cannot just share pointers between the two of them.  If the shared memory segment is coherent between both processes, you can simply use a portion of it as a buffer for text/string data.  You can then pass offsets into the buffer to specify data locations.    Or, you can change the structure to contain a proper array and copy the entire structure to the shared memory area:

                struct sMyData
                {
                    double m_dValue;
                    char   m_cValue;
                    char   m_caValue[ 128 ];
                    int    m_iValue;
                };

                When moving data between processes via some kind of shared memory implementation, you should generally avoid pointers and "real" objects.    Peace! -=- James


                If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                DeleteFXPFiles & CheckFavorites (Please rate this post!)

                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