Solved

Launch OS Calculator

Posted on 2004-09-21
5
275 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
[X]
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
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

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

Suggested Solutions

Title # Comments Views Activity
Making delphi communicate with a c# service 16 123
control image tags in a string ? 12 153
Graphics32 under Delphi 10.1 Berlin 2 128
Browsing a TTreeView in Delphi 5 32
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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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