Solved

Launch OS Calculator

Posted on 2004-09-21
5
273 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
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 censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

785 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