IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

API, COM et SDKs Delphi Discussion :

Utilisation de IShellLinkDataList


Sujet :

API, COM et SDKs Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 18
    Par défaut Utilisation de IShellLinkDataList
    Est ce que quelqu'un sait se servir de cette interface et de la structure EXP_DARWIN_LINK ?

  2. #2
    Rédacteur

    Inscrit en
    Mars 2005
    Messages
    38
    Détails du profil
    Informations forums :
    Inscription : Mars 2005
    Messages : 38
    Par défaut
    Bonjour,

    Quel est le sens de ta question : obtenir la structure ou l'utiliser ?

    Pour l'obtenir ce n'est pas trés compliqué; pour l'utiliser c'est une autre paire de manche...

    Le header Delphi qui défini les structures, objets com (guid...), constantes... est disponible :

    http://www.whirlingdervishes.com/nse...les/source.php


    Pascal

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 18
    Par défaut
    Je cherche a m'en servir pour récupérer les chemins d'accés des apllications winword, etc... à partir des raccourcis.

  4. #4
    Membre émérite

    Profil pro
    Inscrit en
    Mai 2003
    Messages
    582
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Mai 2003
    Messages : 582
    Par défaut
    Nicky,
    j'ai modifier ta fonction pour lire les shortcuts... ca permet de trouver le
    MSI ID de word...
    ca donne la chaine de caractere suivante...pour word2k....
    56,!!gxsf(Ng]qF`H{LsWORDFiles>llT]jI{jf(=1&L[-81-]

    J'ignore cependant comment trouver le path de word a partir de cette string.

    voici la fonction modifier:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
     
    function LoadLink ( aLink: String; var FileLink: TFileLink ): Boolean;
    var
        VBuff: Integer;
        Psl: IShellLink;
        Ppf: IPersistFile;
        FBuff: array [0..260] of Char;
        FLinkFile: array [0..260] of WChar;
        FindData32: WIN32_FIND_DATA;
        //**
        Psldl: IShellLinkDataList;
        sldf:SHELL_LINK_DATA_FLAGS;
        ppDataBlock:Pointer;
        pDarwinData:pExpDarwinLink;
        sMSI_ID:string;
    begin
        VBuff := 0;
     
        Result := False;
     
        MultiByteToWideChar ( CP_ACP, 0, PChar(aLink), -1, FLinkFile, 260 );
     
        CoInitialize ( nil ); 
     
        if ( CoCreateInstance ( CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER, IID_IShellLinkA, Psl ) = S_OK ) then
        begin
            Psl . QueryInterface ( IID_IPersistFile , Ppf );
            Ppf . Load ( FLinkFile , STGM_READ );
            //*** Querry interface to ShellLinkDataList ***
            Psl . QueryInterface (IID_ShellLinkDataList,Psldl);
            //*** try to read shortcut flag ***
            if Psldl.GetFlags( sldf)=S_OK then
            begin
                if ( (sldf and SLDF_HAS_DARWINID)= SLDF_HAS_DARWINID) then
                begin
     
                    //*** here Darwin situation! ***
                    //*** so get information! ***
                    if (Psldl.CopyDataBlock(EXP_DARWIN_ID_SIG ,ppDataBlock)=S_OK)then
                    begin
                        pDarwinData:=ppDataBlock;
                        sMSI_ID :=pDarwinData.szDarwinID;
                        localfree(Cardinal(ppDataBlock));
                        ppDataBlock:=nil
                        //*** Here  sMSI_ID="56,!!gxsf(Ng]qF`H{LsWORDFiles>llT]jI{jf(=1&L[-81-]"
                        //*** But I don't know wath to do with! ***
                    end;
                end;
            end;
            Psl . GetPath ( FBuff , 260 , FindData32 , SLGP_UNCPRIORITY );
            FileLink . Path := FBuff;
            Psl . GetDescription ( FBuff , 260 );
            FileLink . Description := FBuff;
            Psl . GetIconLocation ( FBuff , 260 , VBuff );
            FileLink . IconFile  := FBuff;
            FileLink . IconIndex := VBuff;
            Psl . GetWorkingDirectory ( FBuff , 260 );
            FileLink . WorkingDirectory := FBuff;
            Psl . GetArguments ( FBuff , 260 );
            FileLink . Arguments := FBuff;
            Psl . GetShowCmd ( VBuff );
            FileLink . ShowCmd := VBuff;
            Result := True;
        end;
        CoUninitialize ();
    end;
    la string dans sMSI_ID se retrouve un peut partout dans les registres...
    mais je vois pas comment faire une association avec le path de winword.exe...

    peut-etre quelqu'un a une idée?
    Comment dupliquer un disque...ça vous intéresse?
    Tutoriel et code source delphi ici

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    18
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 18
    Par défaut
    J'ai finit par trouver et ça donne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
     
    //---------------------------------------------------------------------------
    function LoadLink ( aLink: String; var FileLink: TFileLink ): Boolean;
    var
        VBuff: Integer;
        Psl: IShellLink;
        Ppf: IPersistFile;
        FBuff: array [0..260] of Char;
        FLinkFile: array [0..260] of WChar;
     
        aResult: HRESULT;
        ItemList: PItemIDList;
     
    begin
        VBuff := 0;
     
        Result := False;
     
        MultiByteToWideChar ( CP_ACP, 0, PChar(aLink), -1, FLinkFile, 260 );
     
    	CoInitialize ( nil );
     
    	if ( CoCreateInstance ( CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER, IID_IShellLinkA, Psl ) = S_OK ) then
        begin
    		Psl . QueryInterface ( IID_IPersistFile , Ppf );
     
            Ppf . Load ( FLinkFile , STGM_READ );
     
            aResult := Psl . Resolve ( HInstance, SLR_UPDATE or SLR_INVOKE_MSI or SLR_NO_UI );
     
            if ( aResult <> S_OK ) then Exit;
     
            aResult := Psl . GetIDList ( ItemList );
            if ( aResult <> S_OK ) then Exit;
     
            SHGetPathFromIDLIst ( ItemList, FBuff );
            FileLink . Path := FBuff;
     
            Psl . GetDescription ( FBuff , 260 );
    		FileLink . Description := FBuff;
     
            Psl . GetIconLocation ( FBuff , 260 , VBuff );
    		FileLink . IconFile  := FBuff;
            FileLink . IconIndex := VBuff;
     
            Psl . GetWorkingDirectory ( FBuff , 260 );
    		FileLink . WorkingDirectory := FBuff;
     
            Psl . GetArguments ( FBuff , 260 );
    		FileLink . Arguments := FBuff;
     
            Psl . GetShowCmd ( VBuff );
            FileLink . ShowCmd := VBuff;
     
            Result := True;
        end;
     
    	CoUninitialize ();
    end;
    //---------------------------------------------------------------------------
    et avec ça je trouve le bon chemin dans FileLink . Path.

Discussions similaires

  1. utiliser les tag [MFC] [Win32] [.NET] [C++/CLI]
    Par hiko-seijuro dans le forum Visual C++
    Réponses: 8
    Dernier message: 08/06/2005, 15h57
  2. Réponses: 4
    Dernier message: 05/06/2002, 14h35
  3. utilisation du meta type ANY
    Par Anonymous dans le forum CORBA
    Réponses: 1
    Dernier message: 15/04/2002, 12h36
  4. [BCB5] Utilisation des Ressources (.res)
    Par Vince78 dans le forum C++Builder
    Réponses: 2
    Dernier message: 04/04/2002, 16h01
  5. Réponses: 2
    Dernier message: 20/03/2002, 23h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo