For Newbie

Tuesday, 15 November 2011

Execute the file, URL, Email Address with Default Programs with Delphi


Execution files, urls, email addresses by default the program editor.

Use the function:
function ShellExecute (hWnd: HWND; Operation, FileName, Parameters, Directory: PChar; ShowCmd: Integer);

Parameters that you should take:

     FileName: The filename, URL, email address. For the URL, starting with http:// string starts with the string while the e-mail mailto:
     ShowCmd: ie how will the 'executor' is displayed. Param can be SW_SHOWNORMAL (Normal View), SW_MAXIMIZE, SW_HIDE (Runs but on-hide), et al. Can be viewed at {ShowWindow () Commands}

Parent PID (Process ID) program executor (default program) later is PID of your program.

Example execution of files:
ShellExecute (Handle, nil, 'C: \ data1.txt', nil, nil, SW_SHOWNORMAL);

Example execution URL:
ShellExecute (Handle, nil, 'http://opxbit.web.id', nil, nil, SW_SHOWNORMAL);

Example execution of an email address:
ShellExecute (Handle, nil, 'mailto: mockheroicx@yahoo.com', nil, nil, SW_SHOWNORMAL);

In the uses clause add ShellAPI unit.

Share on Facebook
Share on Twitter
Share on Google+

Related : Execute the file, URL, Email Address with Default Programs with Delphi