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


How do i show Run dialog from C code?

Posted on 2009-03-30
Medium Priority
Last Modified: 2013-12-14
How do i show Run dialog from cpp code? I couldn't find a solution on internet :(
Question by:Shershen
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
LVL 46

Expert Comment

by:Kent Olsen
ID: 24020603
Hi Shershen,

If you really are using C++ Builder, simply drop any of the dialog box controls onto your form.  Then from within the C code, execute that box.

  TDiaglog *MyDialog = new ....;
  MyDialog->Execute ()


Author Comment

ID: 24020648
Yes, I'm using c++ builder, but I need to show Run dialog from Start menu.
LVL 46

Expert Comment

by:Kent Olsen
ID: 24020696
It sounds like a communications issue.

By "Start menu" do you mean the "file" menu or something else?

For most any place that you want to show the dialog box, the code is the same.  You simply need to execute it.

Note that dialog boxes are modal, meaning that the user can not access other parts of the application until the dialog box closes.  If you put the dialog box as part of the application's startup code, the user will always have to complete the dialog box before the application can resume.

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 39

Expert Comment

ID: 24021982
>>>> By "Start menu" do you mean the "file" menu or something else?

Probably the Windows Start menu.

I don't know whether there is an Active-X available for Run Dialog, but you easily could make your own using the resource editor, create a dialog instance and call execute member function. and invoke the command entered by the user via ShellExecute.

  TDialog * ptrRunDialog = new MyRunDialog();
  ptrRunDialog->Execute ();


Author Comment

ID: 24023030
Seems my english is quite bad :)

Press Win+R - I need to show this dialog from my program, using some API function or interface or rundll32 or something else.
LVL 46

Expert Comment

by:Kent Olsen
ID: 24023655
Ok.  If I get this correct...

The application's main form (just like any other form) traps a bunch of events that you can process.

Create an OnKeyPress event handler for the main form.  (In the "Object Inspector", click the "Events" tab, then double click OnKeyPress.  The IDE will create the method and put you into the editor within the new method.

Within the handler, check to see if the value of Key is what you want.  (I have no idea what the Win+R key combination is.)  If it is your key, open the dialog box as shown above and set the value of Key to 0 (zero) before the method exits.  If the value of Key is not a keypress that you want to handle, simply leave it alone

Good Luck,

void fastcall TMainForm::FormKeyPress (TObject *Sender, char &Key)
  if (Key == 'R')  // Key on 'R' (as an example)
    TDiaglogBox *Dialog = new TDialogBox (this);
    if (Dialog->Execute ())
//      Do Something
    Key = 0;

Open in new window


Accepted Solution

Shershen earned 0 total points
ID: 24023695
Solved by this code:

Variant V;
V = CreateOleObject("Shell.Application");
LVL 49

Expert Comment

ID: 24023865
Shershen, Good job, You have solved this yourself!  Click the "Accept As Solution" button in your above answer.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

715 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