Click here to Skip to main content
15,895,011 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Runtime Error while word 2010 Automation, "A null refrence pointer was passed to the stub." Pin
Niklas L9-Jul-10 3:14
Niklas L9-Jul-10 3:14 
GeneralRe: Runtime Error while word 2010 Automation, "A null refrence pointer was passed to the stub." Pin
m_code9-Jul-10 5:20
m_code9-Jul-10 5:20 
QuestionFile Mapping Pin
john56328-Jul-10 22:31
john56328-Jul-10 22:31 
AnswerRe: File Mapping Pin
Niklas L8-Jul-10 22:37
Niklas L8-Jul-10 22:37 
GeneralRe: File Mapping Pin
john56328-Jul-10 23:10
john56328-Jul-10 23:10 
GeneralRe: File Mapping Pin
Niklas L9-Jul-10 1:52
Niklas L9-Jul-10 1:52 
AnswerRe: File Mapping Pin
KarstenK8-Jul-10 22:50
mveKarstenK8-Jul-10 22:50 
AnswerRe: File Mapping Pin
Aescleal8-Jul-10 23:40
Aescleal8-Jul-10 23:40 
You have to work out how you're going to marshal (as in railway marshalling, not US law enforcement officer) your data from one process to another.

Generally you have an intermediate form that you write into your shared memory and then read out again in the other process. Say you have a class:

class A
{
    public:
        std::string text_;
};


You can't just use something like placement new, copy it into the shared memory and expect it to work. The string's characters could be anywhere in the source address space. One solution is to treat the shared memory like a file - you can write the characters and how many of them there are into the shared memory and read them out on the other side:

class A
{
    public:
        std::string text_;

        void raw_memory_write( void *where );
        void raw_memory_read( void *where );
};


Once you've implemented this pair you have to work out how to signal the other process that there's an object to read AND, if you want bidirectional comms, avoid writing to the same memory (you can use two blocks for this, one for each process to write into and the other to read from). While there are ways of doing this if you don't know what you're doing it can backfire horribly.

An alternative to using shared memory is to use an interprocess comms mechanism that's already out there and works. For example sockets if it has to be portable. That way all you have to worry about is reading/writing a stream of bytes from something that looks surprisingly like a file. And it's less code to write a simple sockets client/server pair than manage all the detritus around shared memory.

Cheers,

Ash
QuestionHow to resize a dialogbar Pin
ilgale8-Jul-10 21:27
ilgale8-Jul-10 21:27 
QuestionListBox Pin
AbhiHcl8-Jul-10 20:57
AbhiHcl8-Jul-10 20:57 
AnswerRe: ListBox Pin
MsmVc8-Jul-10 21:17
MsmVc8-Jul-10 21:17 
GeneralRe: ListBox Pin
AbhiHcl8-Jul-10 21:31
AbhiHcl8-Jul-10 21:31 
GeneralRe: ListBox Pin
Niklas L8-Jul-10 22:28
Niklas L8-Jul-10 22:28 
GeneralRe: ListBox Pin
AbhiHcl9-Jul-10 0:20
AbhiHcl9-Jul-10 0:20 
GeneralRe: ListBox Pin
Niklas L9-Jul-10 1:56
Niklas L9-Jul-10 1:56 
GeneralRe: ListBox Pin
AbhiHcl9-Jul-10 2:24
AbhiHcl9-Jul-10 2:24 
GeneralRe: ListBox Pin
Niklas L9-Jul-10 2:26
Niklas L9-Jul-10 2:26 
QuestionString Pin
T.RATHA KRISHNAN8-Jul-10 20:42
T.RATHA KRISHNAN8-Jul-10 20:42 
AnswerRe: String Pin
«_Superman_»8-Jul-10 20:48
professional«_Superman_»8-Jul-10 20:48 
AnswerRe: String Pin
Aescleal8-Jul-10 21:21
Aescleal8-Jul-10 21:21 
QuestionWhy References and pointers cannot be used on constructors and destructors Pin
pandit848-Jul-10 19:45
pandit848-Jul-10 19:45 
AnswerRe: Why References and pointers cannot be used on constructors and destructors Pin
«_Superman_»8-Jul-10 20:24
professional«_Superman_»8-Jul-10 20:24 
GeneralRe: Why References and pointers cannot be used on constructors and destructors Pin
pandit848-Jul-10 20:33
pandit848-Jul-10 20:33 
QuestionHow to change a Button caption Pin
raju_shiva8-Jul-10 18:59
raju_shiva8-Jul-10 18:59 
AnswerRe: How to change a Button caption Pin
«_Superman_»8-Jul-10 19:22
professional«_Superman_»8-Jul-10 19:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.