Answered by:
#pragma data_seg(".SHARED") char *

Question
-
How can u share allocated memory with multiple instance of the DLL???
For example,
#pragma data_seg(".SHARED")
bool g_bIsDeviceInUse = false;
unsigned char *pucBuffer = NULL;
#pragma data_seg()
#pragma comment(linker, "/section:.SHARED,RWS")I can see that g_bIsDeviceInUse is showing the right value even if checked with this instance or another instance of DLL, but not for pucBuffer. If once instance allocated the memory and set pucBuffer to a value (e.g., "Summer"), but another instance will not show a value for pucBuffer, even though both instance shows the same memory location for pucBuffer.
- Moved by Xingyu ZhaoMicrosoft contingent staff Thursday, March 19, 2020 8:29 AM
Wednesday, March 18, 2020 6:36 PM
Answers
-
Hello,
your source code looks like C++ in Visual Studio. So ask here: https://social.msdn.microsoft.com/Forums/en-US/home?forum=vcgeneral
- Proposed as answer by Richard MuellerMVP, Banned Thursday, March 19, 2020 9:18 AM
- Marked as answer by Dave PatrickMVP Wednesday, March 25, 2020 3:57 PM
Thursday, March 19, 2020 9:15 AM
All replies
-
The docs are old but they explain why trying to use a pointer in a shared data segment won't work as you expect.
Wednesday, March 18, 2020 6:49 PM -
why do you ask this in the forum ".NET Framework Class Libraries"?Wednesday, March 18, 2020 9:26 PM
-
Hi Ming Chee Chang,
Thank you for posting here.
In order to help you find the correct forum to go ask questions, I have moved the thread to Where is the forum for? forum.
Best Regards,
Xingyu Zhao
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Thursday, March 19, 2020 8:28 AM -
Hello,
your source code looks like C++ in Visual Studio. So ask here: https://social.msdn.microsoft.com/Forums/en-US/home?forum=vcgeneral
- Proposed as answer by Richard MuellerMVP, Banned Thursday, March 19, 2020 9:18 AM
- Marked as answer by Dave PatrickMVP Wednesday, March 25, 2020 3:57 PM
Thursday, March 19, 2020 9:15 AM