Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 137
  • Last Modified:

Open assosiated programs for assosiated files.

I want to make a small prog to open a powerpoint presentation thru powerpoint automaticly.

I just want to get the assosiated program & parameters for a eg. extention '.pps'.

(I know I can just dubble click on the file, but I want to give this to some people that doesn't understand the concept)
0
Stream12
Asked:
Stream12
1 Solution
 
MotazCommented:
- Add shellApi to uses clause
- Call ShellExecute(handle, 'open', PChar(FileName), nil, nil, sw_Normal);

where FileName is a string containing power point presentation file name

Motaz
0
 
SimesACommented:
This code gets the associated program:

function GetAssociateFileType(const FileType: string): string;
var
  reg: TRegistry;
  FileTypeName: string;
  p: integer;
begin
  result := '';
  reg := TRegistry.Create;
  try
    reg.RootKey := HKEY_CLASSES_ROOT;
    if reg.OpenKey(FileType, false) then begin
      FileTypeName := reg.ReadString('');
      reg.CloseKey;
    end;

    reg.RootKey := HKEY_CLASSES_ROOT;
    if reg.OpenKey(FileTypeName + '\Shell\Open\Command', false) then begin
      result := reg.ReadString('');
      reg.CloseKey;
    end;
    if result <> '' then
      if result[1] = '"' then begin
        delete(result, 1, 1);
        p := Pos('"', result);
        if p <> -1 then
          delete(result, p, length(result) - p + 1);
      end;
  finally
    reg.free;
  end;
end;
0
 
Stream12Author Commented:
Thank you both,

I tried both answers and both work. Wish I could split the points.

I chose Motaz's anwser because it's shorter.

Also, with SimesA solution I don't get the parameters on output.
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.

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