CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2005
    Posts
    63

    Passing a handle between processes

    Hi,
    I am researching if it is possible to pass a handle to the serial port to another process. If I have process A that opened a handle to the serial port and then process A forks a new process B (If even possible) by calling an execultable on the hardrive. Can process A pass the handle as a command line argument to process B or maybe put the address in the registry where process B can access it. Thanks
    Amish

  2. #2
    Join Date
    Jun 2002
    Posts
    1,417

    Re: Passing a handle between processes

    child process inherits all handles of the parent. Its not necessary to pass anything from parent to child because child already knows about the open handles.

    http://www.hmug.org/man/2/fork.php

    >>maybe put the address in the registry

    *nix doesn't have anything called "the registry" -- that's an MS-Windows term. And MS-Windows doesn't "fork" new processes, that's a *nix term. Which operating system are you using anyway?
    Last edited by stober; December 16th, 2005 at 05:04 PM.

  3. #3
    Join Date
    Jan 2005
    Posts
    63

    Re: Passing a handle between processes

    Sorry,
    I forgot to add that, I will be using Windows. I guess I get confused with all the fuctions between linux and windows. Is there anything like fork in windows.
    Amish

  4. #4
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Passing a handle between processes

    Processes in Windows can be created using an API like CreateProcess.

    One parameter of interest to you might be -
    Code:
    BOOL CreateProcess(
    		   LPCTSTR lpApplicationName,
    		   LPTSTR lpCommandLine,
    		   LPSECURITY_ATTRIBUTES lpProcessAttributes,
    		   LPSECURITY_ATTRIBUTES lpThreadAttributes,
    		   BOOL bInheritHandles,
    		   DWORD dwCreationFlags,
    		   LPVOID lpEnvironment,
    		   LPCTSTR lpCurrentDirectory,
    		   LPSTARTUPINFO lpStartupInfo,
    		   LPPROCESS_INFORMATION lpProcessInformation
    		   );

  5. #5
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Passing a handle between processes

    [ redirected ]

    Regards,
    Siddhartha

  6. #6
    Join Date
    Jan 2005
    Posts
    63

    Re: Passing a handle between processes

    Sweet that fits my design. Thanks a lot,
    Amish

  7. #7
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Passing a handle between processes

    You are welcome...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured