Solved

Starting Email & Browser From My App

Posted on 2001-08-21
5
153 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
5 Comments
 
LVL 4

Accepted Solution

by:
YodaMage earned 300 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
What else do you need?
0
 
LVL 6

Author Comment

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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now