Solved

Launch OS Calculator

Posted on 2004-09-21
5
271 Views
Last Modified: 2010-04-05
Can any experts please tell me how to launch the OS Calc?  I want to have an option in a menu list that say 'Launch Calculator', when this is clicked on the windows calc will launch.  Is this done via ShellExecute??

Thanks in advance...
0
Comment
Question by:zork007
5 Comments
 
LVL 7

Accepted Solution

by:
LRHGuy earned 75 total points
ID: 12119333
This works for me:

Uses ShellApi;

procedure TForm2.Button1Click(Sender: TObject);
var
  param:string;
begin
  param:='calc';
  ShellExecute(GetDeskTopWindow
              ,'open'
              ,pChar(Param)
              ,nil
              ,nil
              ,SW_SHOWNORMAL
              );

end;
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12120761
Calc.exe is usually stored in System32 Folder so you can simply use winexec

Winexec('calc',SW_SHOWNORMAL);
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12122188
The use of WinExec is actually discouraged, F68. Problem is that MicroSoft actually wanted to kicked this function out of the Windows API. Unfortunately there's too much code that depends on this API function, thus in XP there's something called compability mode that brings it back again. But in general either use ShellExecute(Ex) or CreateProcess. ShellExecute, like LHRGuy already said, is the preferred method.
However, some users might have uninstalled Calc while other users might have another application called calc.exe somewhere in their path. So you might want to add the Windows path in front of the executable name...
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12122673
I agree with you WA...
In fact i usually use ShellExecute or CreateProcess (for console style executions) in  my apps.
I was just adding an alternative as LHRGuy had already explained about the SHellexecute stuff

F68 ;-)
0
 

Author Comment

by:zork007
ID: 12130244
Thanks guys, I have used the code supplied by LRHGuy.  Thanks for all your advise.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

21 Experts available now in Live!

Get 1:1 Help Now