• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

ShellExecute question

Is there a way to use ShellExecute to open the default word processor for a new blank document?  If not, is there a way to do this?

Thanks.
0
alexiat
Asked:
alexiat
  • 2
  • 2
1 Solution
 
ChristianWimmerCommented:
Many wps shows a blank document if they are ran without any parameters.
You can retrieve the linked application for a file extension using the LookupRegisteredApp function source supplied by this codeproject article :
http://www.codeproject.com/KB/shell/ExecApp.aspx
0
 
alexiatAuthor Commented:
I don't suppose you know of anything written in Delphi, not in C?
0
 
ChristianWimmerCommented:
Unfortunately, I don't know any code in Delphi. JCL and JVCL implements a function that you could adapt to your needs:
from JCL/JVCL:
 
procedure AssociateFileExtension(IconPath, ProgramName, Path, Extension: string);
begin
  with TRegistry.Create do
  begin
    RootKey := HKEY_CLASSES_ROOT;
    OpenKey(ProgramName, True);
    WriteString('', ProgramName);
    if IconPath <> '' then
    begin
      OpenKey(RC_DefaultIcon, True);
      WriteString('', IconPath);
    end;
    CloseKey;
    OpenKey(ProgramName, True);
    OpenKey('shell', True);
    OpenKey('open', True);
    OpenKey('command', True);
    WriteString('', '"' + Path + '" "%1"');
    Free;
  end;
  with TRegistry.Create do
  begin
    RootKey := HKEY_CLASSES_ROOT;
    OpenKey('.' + extension, True);
    WriteString('', ProgramName);
    Free;
  end;
  RebuildIconCache;
end;

Open in new window

0
 
alexiatAuthor Commented:
Thanks.  I searched and couldn't find anything but figured you experts would know for sure.  As usual, deadlines loom and I didn't want to spin my wheels.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now