Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


opening a DialogEX from outside the EXE

Posted on 2006-06-18
Medium Priority
Last Modified: 2010-04-05
Hi guys, i'm kinda stuck with a idea.

I have a program that have some Custon Dialogs.

These dialogs have their handles when they are opened. When they get closed the only handle that remains is the main program.

1 - Is there a way to open these Custon Dialogs from outside the program (like if another program force them to show) ?
2 - If yes, what information I need to know to perform this action ?

I can find some Custom Dialogs inside the EXE by using the PE Explorer but i don't know if the information PE Explorer gives to me is enough to perform my action.

ty in adv
Question by:furmiga
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
LVL 17

Accepted Solution

TheRealLoki earned 1000 total points
ID: 16931078
to show a dialog in another application, where you have the handle for the dialog, you *can* do
    showwindow(thehandle, sw_show);
I'm not sure how it would handle the close message though (ie. if youthen tried to close the dialog)
Also, if you have not previously shown the dialog, you may not get the controls appearing.
if program A had not created the form, or it uses "ShowModal" or frees it, then you will not have a handle.

If you wrote both programs, then you could have Program B simply ask Program A to show it
ie. Program B does: PostMessage(program1handl, wm_uer+100, 1, 0); // 1 meaning "please show dialog 1 thanks"
(Program A has a routine to catch this message)

If you want Program B to get any properties from the dialog, then you may be better off putting the dialogs in a shared DLL for both programs to access.

Author Comment

ID: 16931423
Hey man thx for the reply.

The problem is that after I close the dialog, the hadler created for it disappears and even if I save the handle I cant open it from outside the program.

LVL 17

Expert Comment

ID: 16931597
if you just do a show, and a close, you can "reshow" it again
I did a simple demo
where i had 2 forms in the .dpr being created, and form 1 had a button that said ""
and button2 said caption := inttostr(form2.handle)
the handle was the same.. in fact, if i put text in an edit box on form2, it stays the same also.
I then tried "showwindow(thehandle, sw_show);" from another application, which worked.
so um.. my point is, you can reshow it, but not if you are dynamically creating it
(e.g. with TMyDialog1.create(self) do try showmodal; finally free; end; ) <-- this will lose the handle

Does "Program 2" need to get data from the dialog?
Are you writing Program 1 and Program 2? (ie. how much design scope do you have, so we can get this working)
Does this have to work from a remote machine, or are they both on the same machine?
When Program 2 makes the dialog appear, do you want program 1 to "wait" until the dialog is closed?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 16934935
All i want is activate the menu in program 2, using the program 1 for it. The menu in program 2 is a normal menu "file - etc - etc - about" but this menu only exists inside the EXE. It never shows. When you use some resource app you can see the menu inside it but, again, it never really shows. The app don't allocate handlers for the menu either. I'm just wondering if there is a possibility to show this menu (or inject a code to force it to open). There is no possibility to change the code in app2 since all i have is it's executable.
LVL 34

Assisted Solution

Slick812 earned 1000 total points
ID: 16936152
hello furmiga , , I am not sure about some of the things you talk about, ,
First, in the program that you want to call the "DialogEx" and "Menu", , are these 2 a "Resource" compiled, ,  or are they "run time created" without any resouce reference. . .  as far as I can tell from your comments, They are in the programs resource set.
If these are in the resource, then I beleive you can load the executable as a library as in
hLibrary := LoadLibrary('C:\\Folder1.prog.exe');
 , and then do an API like CreateDialog( ) or  DialogBox( ) and use the hLibray as the resource hInstance.
Seems like there is also a LoadMenu( ) function

Author Comment

ID: 16936639
Hi Slick thanks for the reply.

Look what I have:

PE Explorer.exe --> This program alows anyone to view and change some dll / exe resources. It shows Dialogs, menus, strings, icons etc.

Program.exe --> This is the program I want to change.

Now, when I load Program.exe into PE Explorer I can see 3 menus and some dialogs.

These menu / Dialogs never appear in the Program.exe (when it's running) But they are inside the Program.exe somewhere as we can see in the PE Explorer.

My question is: How can I "force" program.exe to open these Dialogs while its running ? I don't know if they will interact with the proram.exe since they are not actualy beeing called by real situations but still, is there any chance to open them ?

LVL 34

Expert Comment

ID: 16938899
OH, I see a little more now, ,  
The program called  Program.exe, when it is running, will be doing what it was designed to do (programming of its code), but you want to have another program (your program) run code inside this running Program.exe. . . as I understand your last comment? . . .
I have tried to "Hack" into other running programs to try and get some minor information, but I can tell you, trying to do anything in another program (other memory space) is a really difficult thing. . . and for the most part (my opinion) a NON Productive effort, you may could execute a resource DIALOGEX in another process memory space, however, you will have no easy way (maybe no way) to route that DIALOGEX window to use the "code" (window message function ect) inside that other program,  I think it may be posible to dis-assemble some 32-bit programs and get some hints as to the function memory positions, but I do not think here at EE Delphi, that this is the place for such advanced programming methods.
Have you any experience in getting into the memory space of anothe running program? It is a hassel, much trouble for me.

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question