Usage of CoTaskMemAlloc?

后端 未结 5 1550
攒了一身酷
攒了一身酷 2020-12-06 01:12

When is it appropriate to use CoTaskMemAlloc? Can someone give an example?

5条回答
  •  [愿得一人]
    2020-12-06 01:53

    CoTaskMemAlloc is same as malloc except that former is used to allocate memory which is used across process boundaries.

    i.e., if we have two processes, process1 and process2, assume that process1 is a COM server, and process2 is a COM Client which uses the interfaces exposed by process1. If process1 has to send some data, then he can allocate memory using CoTaskMemAlloc to allocate the memory and copies the data. That memory location can be accessed by process2.

    COM library automatically does the marshalling and unmarshalling.

提交回复
热议问题