Results 1 to 3 of 3

Thread: Bestandsextensies

  1. #1
    Member Chilly-B's Avatar
    Join Date
    Jun 2001
    Location
    Hoogeveen
    Posts
    62

    Question Bestandsextensies

    Hallo allemaal,

    Als ik via de windowsverkenner een Word-documentje aanklik dan start Word op
    met het bijbehorende documentje. Een *.doc bestand is dus ergens in het register
    gekoppeld aan het programma MS-Word.

    Hoe kan ik checken of een bepaalde extensie al gekoppeld is aan een programma?

    groeten,

    Martijn

  2. #2
    Senior Member rieni's Avatar
    Join Date
    Mar 2001
    Location
    Br?©ttum bij Lillehammer, Noorwegen
    Posts
    342

    Post

    Idee:

    Je kunt ze vinden in de registry onder:

    HKey_Classes_Root,

    maar ook..

    HKey_Local_Machine => Software => Classes

    Daar zie je of jouw evt. extensie al wordt gebruikt.

    Rieni

  3. #3
    Member Chilly-B's Avatar
    Join Date
    Jun 2001
    Location
    Hoogeveen
    Posts
    62

    Smile

    Bedankt! Maar ik had vanmiddag net wat gevonden:

    Code:
    implementation
    
    {$R *.DFM}
    
    uses
    {$IFDEF WIN32}
      Registry; {We will get it from the registry}
    {$ELSE}
      IniFiles; {We will get it from the win.ini file}
    {$ENDIF}
    
    {$IFNDEF WIN32}
      const MAX_PATH = 144;
    {$ENDIF}
    
    {-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}
    
    function GetProgramAssociation (Ext : string) : string;
    var 
    {$IFDEF WIN32} 
      reg: TRegistry;
      s : string; 
    {$ELSE} 
      WinIni : TIniFile;
      WinIniFileName : array[0..MAX_PATH] of char; 
      s : string; 
    {$ENDIF}
    begin 
    {$IFDEF WIN32} 
      s := '';
      reg := TRegistry.Create; 
      reg.RootKey := HKEY_CLASSES_ROOT; 
      if reg.OpenKey('.' + ext + '\shell\open\command',
                     false) <> false then begin 
      {The open command has been found} 
        s := reg.ReadString('');
        reg.CloseKey; 
      end else begin 
      {perhaps thier is a system file pointer}
        if reg.OpenKey('.' + ext, 
                       false) <> false then begin 
          s := reg.ReadString('');
          reg.CloseKey; 
          if s <> '' then begin 
         {A system file pointer was found}
            if reg.OpenKey(s + '\shell\open\command', 
                           false) <> false then 
         {The open command has been found}
              s := reg.ReadString(''); 
            reg.CloseKey; 
          end;
        end; 
      end; 
    {Delete any command line, quotes and spaces}
      if Pos('%', s) > 0 then 
        Delete(s, Pos('%', s), length(s));
      if ((length(s) > 0) and
          (s[1] = '"')) then
        Delete(s, 1, 1);
      if ((length(s) > 0) and
          (s[length(s)] = '"')) then
        Delete(s, Length(s), 1);
      while ((length(s) > 0) and
             ((s[length(s)] = #32) or
              (s[length(s)] = '"'))) do
        Delete(s, Length(s), 1);
    {$ELSE}
      GetWindowsDirectory(WinIniFileName, sizeof(WinIniFileName));
      StrCat(WinIniFileName, '\win.ini');
      WinIni := TIniFile.Create(WinIniFileName);
      s := WinIni.ReadString('Extensions',
                              ext,
                              '');
      WinIni.Free;
    {Delete any command line}
      if Pos(' ^', s) > 0 then
        Delete(s, Pos(' ^', s), length(s));
    {$ENDIF}
      result := s;
    end;
    
    {-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      ShowMessage(GetProgramAssociation('pdf'));
    end;
    
    {-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •