Shared Memory Writing
-
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
-
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
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:
-
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:
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?
-
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
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 likestrcpy
in non-Unicode orwcscpy
in Unicode mode. (If you uselstrcpy
orStrCpy
, 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. -
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
-
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?
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
-
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
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!)