opening a DialogEX from outside the EXE

Posted on 2006-06-18
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
  • 3
  • 2
  • 2
LVL 17

Accepted Solution

TheRealLoki earned 250 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?
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.


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 33

Assisted Solution

Slick812 earned 250 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 33

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 10 Seattle Dataset Actions 5 78
ddeman not working in activex 3 93
calling Tcolordialog in dll make the form disappear 8 103
add combobox item based on numbers 9 122
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now