Go Premium for a chance to win a PS4. Enter to Win


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
  • 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 "form2.show"
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?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

783 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