Click here to Skip to main content
15,894,062 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Using handle between two process Pin
CPallini9-Jan-08 23:47
mveCPallini9-Jan-08 23:47 
GeneralRe: Using handle between two process Pin
Maxwell Chen10-Jan-08 0:19
Maxwell Chen10-Jan-08 0:19 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 0:36
mveCPallini10-Jan-08 0:36 
GeneralRe: Using handle between two process Pin
Maxwell Chen10-Jan-08 3:48
Maxwell Chen10-Jan-08 3:48 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 3:58
mveCPallini10-Jan-08 3:58 
GeneralRe: Using handle between two process Pin
Maxwell Chen10-Jan-08 4:08
Maxwell Chen10-Jan-08 4:08 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 4:35
mveCPallini10-Jan-08 4:35 
GeneralRe: Using handle between two process [modified] Pin
CPallini10-Jan-08 4:18
mveCPallini10-Jan-08 4:18 
Maxwell Chen wrote:
I am not sure, but if it is just a number, a ULONG is just fine. Since it is defined as a pointer type (void*), it must be some address pointing to something.


(1) Just a number? a memory address is a number. A window handle is more than a memory address: it is a unique number in the system context (i.e. the same for all processes) identifying one particular window. Even supposing it is a memory address it cannot be a memory address in the context of any process in the user space, i.e. deferencing it in such processes is meaningless.


Maxwell Chen wrote:
I guess that creating handle and free handle are something related with global allocating memory blocks in the heap

There's no hope to obtain shared memory the way you depicted. the reinterpret_cast has nothing to do with it (BTW it acts always in the context of the running process and it doesn't changes the pointer address). If you want shared memory you've to ask Windows a HANDLE, i.e. a number: the OS itself will never return to you a direct pointer to.

MSDN [^] states:

Memory objects allocated by GlobalAlloc and LocalAlloc are in private, committed pages with read/write access that cannot be accessed by other processes. Memory allocated by using GlobalAlloc with GMEM_DDESHARE is not actually shared globally as it is in 16-bit Windows. This value has no effect and is available only for compatibility. Applications requiring shared memory for other purposes must use file-mapping objects. Multiple processes can map a view of the same file-mapping object to provide named shared memory. For more information, see File Mapping.


[added]
See also http://en.wikibooks.org/wiki/Windows_Programming/Handles_and_Data_Types[^]
[/added]

Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

[my articles]


modified on Thursday, January 10, 2008 10:29:24 AM

GeneralRe: Using handle between two process Pin
Maxwell Chen10-Jan-08 4:36
Maxwell Chen10-Jan-08 4:36 
GeneralRe: Using handle between two process Pin
Mark Salsbery10-Jan-08 7:19
Mark Salsbery10-Jan-08 7:19 
GeneralRe: Using handle between two process Pin
Hamid_RT9-Jan-08 23:47
Hamid_RT9-Jan-08 23:47 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 0:22
mveCPallini10-Jan-08 0:22 
GeneralRe: Using handle between two process Pin
Hamid_RT10-Jan-08 0:34
Hamid_RT10-Jan-08 0:34 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 0:47
mveCPallini10-Jan-08 0:47 
GeneralRe: Using handle between two process Pin
Nishad S9-Jan-08 23:52
Nishad S9-Jan-08 23:52 
GeneralRe: Using handle between two process Pin
ashtwin10-Jan-08 1:19
ashtwin10-Jan-08 1:19 
GeneralRe: Using handle between two process Pin
Nishad S10-Jan-08 1:43
Nishad S10-Jan-08 1:43 
GeneralRe: Using handle between two process Pin
CPallini10-Jan-08 2:16
mveCPallini10-Jan-08 2:16 
GeneralRe: Using handle between two process Pin
David Crow10-Jan-08 2:19
David Crow10-Jan-08 2:19 
GeneralRe: Using handle between two process Pin
ashtwin10-Jan-08 18:32
ashtwin10-Jan-08 18:32 
GeneralRe: Using handle between two process Pin
David Crow11-Jan-08 2:29
David Crow11-Jan-08 2:29 
GeneralAbout wavein API Pin
minihotto9-Jan-08 23:26
minihotto9-Jan-08 23:26 
QuestionRe: About wavein API Pin
Mark Salsbery10-Jan-08 7:38
Mark Salsbery10-Jan-08 7:38 
GeneralRe: About wavein API [modified] Pin
minihotto10-Jan-08 17:49
minihotto10-Jan-08 17:49 
GeneralRe: About wavein API Pin
Mark Salsbery11-Jan-08 6:51
Mark Salsbery11-Jan-08 6:51 

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.