Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3309996
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:42:25+00:00 2026-05-17T21:42:25+00:00

My program will sometimes be launched from another program. If that’s the case, I

  • 0

My program will sometimes be launched from another program. If that’s the case, I want to be able to send messages back and forth between the two programs using WM_COPYDATA.

After my child program launches, how can it get the HWND for the calling program? Is there a function I can call to do it, or can I do it indirectly, e.g. get the process ID of the calling program and then go from that to an HWND?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:42:26+00:00Added an answer on May 17, 2026 at 9:42 pm

    There’s a slight problem involved. A single calling program can have multiple HWND’s, from multiple windows. And no, I’m afraid there isn’t a way to get the calling program’s PID or something similar. There is no way to get the “parent” process of your process, at least in Windows. You can’t do anything without knowing the name of the calling function, then you can look up it’s PID and get a list of its active windows.

    I suggest working backwards, passing the calling process’s HWND as a command line parameter to your program. e.g. “start YourProgram.exe /hwnd:1234”

    EDIT: I just found out that there IS a way, but just not supplied by Windows. http://www.codeproject.com/KB/threads/ParentPID.aspx . But there is a caveat. PIDs are generated and recycled constantly, so if you do get the PID, no guarentee its parent isn’t dead (crash or ended process) and the PID being used by something else. Then interacting with the supposed parent process will become highly dangerous and instable. So yes, you can do it. But be careful, if the parent crashes, and you attempt to access it via its old PID, you’ll be running into major problems, particularly if you accidentally inject something into, say, the Windows service host.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a program that will bootstrap another program, so as a result
I have the below program that will move files from one directory to other.
I'm making a program that will move around quite huge sets of files, sometimes
When i run this program, it appears that sometimes 55 will be printed out,
I have a program that segfaults from pointer arithmetic sometimes. I know this happens,
My python program receives MIDI data from a C library. Sometimes the data will
As we all know Java program will start executing from the public static void
When writting an updater for a program, I quickly realized that the program will
I have a program that will let me manage users on our terminal server
I am building a program that will update an early voted column in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.