Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Launch OS Calculator

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

Hire Technology Freelancers with Gigs

Work with 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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

604 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