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

x
?
Solved

Starting Email & Browser From My App

Posted on 2001-08-21
5
Medium Priority
?
163 Views
Last Modified: 2010-04-06
What is the code that I need to use that would open a user's default email or web browser program depending upon which button they clicked on.  I know I need to use the onClick event.  This code must also be compatible with W2K, NT, ME, and 9x.  I have heard there are issues with ShellExecute and W2K and have been told to use CreateProcess instead.  Also, does my app. need to care about what happens to the email and web browser program.  As far as I am concerned, I don't care when the user returns to my program.  They can go back and forth between the two.

Therefore, the solution I am looking for is the code to open email and web browser using the CreateProcess API from an onClick event.
0
Comment
Question by:tecbuilder
[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 4

Accepted Solution

by:
YodaMage earned 1200 total points
ID: 6410929
var
  StartInfo : _STARTUPINFOA;
  ProcessInfo : _PROCESS_INFORMATION;
begin
  GetStartupInfo(startinfo);
  CreateProcess('*.exe', PChar('*.exe'), nil,
  nil, false, CREATE_NEW_CONSOLE,
  nil, nil, StartInfo, ProcessInfo);
end;

Just replace my *.exe with the file you need to open. This will not open the default though, and create process cannot open a default as far as I know. You'll have to write the code to determine the appropriate exe.

I use shellexecute and have had no problem on w2k.
Code as  taken from my app:

var
  temp : string[50];
begin
  temp := qryfirm.fieldbyname
   ('client_procede_path').asstring;
  ShellExecute(Handle, 'OPEN', PChar(temp + '\' +
   edproc.text), nil, nil, SW_MAXIMIZE);
end;

*edproc.text is the name of an html file.
0
 
LVL 2

Expert Comment

by:RickHalle
ID: 6411031
I agree. ShellExecute has not given me any problems either. CreateProcess will work but you need to know the exe to execute in advance.

Here is what I am using for URL's and Email:

procedure ShellOutRun(sUrl: String);
begin
  sUrl := Trim(sUrl);
  ShellExecute(0, Nil, PChar(sUrl), Nil, Nil, SW_NORMAL);
end;

Rick Halle
0
 

Expert Comment

by:eshipman
ID: 6411595
uses ...,ShellApi;

procedure TForm1.BrowseTo(sURL, sBrowser, sDir :String);
var
 sei: TShellExecuteInfo;
begin
 ZeroMemory(@sei, sizeof(sei));
 with sei do
 begin
   cbSize := SizeOf(sei);
   fMask  := SEE_MASK_NOCLOSEPROCESS;
   Wnd   := Form1.Handle;
   lpVerb := 'open';
   // Need to see if sBrowser empty, if so, pass url to lpFile parameter
   if sBrowser <> #0 then
     lpFile := PChar(sBrowser)
   else
     lpFile := PChar(sURL);
   lpParameters := PChar(sURL);
   lpDirectory := PChar(sDir);
   nShow := SW_SHOWNORMAL;
 end;
 ShellExecuteEX(@sei);
end;

procedure TForm1.btnBrowseToClick(Sender: TObject);
begin
 BrowseTo('http://www.experts-exchange.com', '',
          '');
end;

procedure TForm1.btnEmailToClick(Sender: TObject);
begin
 BrowseTo('mailto:bill_gates@microsoft.com', '',
          '');
end;

0
 
LVL 4

Expert Comment

by:YodaMage
ID: 6418219
What else do you need?
0
 
LVL 6

Author Comment

by:tecbuilder
ID: 6418468
28 hour days.  :)  Sorry for the delay.  Thanks for your help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Loops Section Overview
Suggested Courses

610 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