?
Solved

Launch OS Calculator

Posted on 2004-09-21
5
Medium Priority
?
278 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 300 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 23

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 23

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

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.

Question has a verified solution.

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

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

765 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