Solved

Starting Email & Browser From My App

Posted on 2001-08-21
5
159 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 300 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

688 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