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

 Delphi Discussion :

[D7] [W10] Récupérer le répertoire téléchargement de W10


Sujet :

Delphi

  1. #1
    Membre expert
    Avatar de Charly910
    Homme Profil pro
    Ingénieur TP
    Inscrit en
    Décembre 2006
    Messages
    2 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur TP
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 374
    Points : 3 152
    Points
    3 152
    Par défaut [D7] [W10] Récupérer le répertoire téléchargement de W10
    Bonjour,

    je voudrais récupérer le nom du répertoire Téléchargements de W10. ça parait simple, mais je n'y arrive pas !

    J'ai vu qu'il fallait utiliser SHGetKnownFolderPath, alors j'ai fait :

    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
      // Code de : https://github.com/yypbd/yypbd-Delphi-Libs/blob/master/lib/ShellKnownPath.pas
    Uses ... ,Shlobj, SHFolder;
     
    Const
      FOLDERID_Downloads: TGUID =  '{374DE290-123F-4565-9164-39C4925E467B}';  // Je pense utiliser celui-ci
      FOLDERID_PublicDownloads: TGUID = '{3D644C9B-1FB8-4f30-9B45-F670235F79C0}';
     
    { ====================================================================== }
    function TF_Princ.GetFolderPathW10(const AFolderID: TGUID): string;
    var
      hr: HRESULT;
      pszPath: PWideChar;
    begin
      Result := '';
     
      hr := SHGetKnownFolderPath( AFolderID, 0, 0, pszPath );
      if Succeeded(hr) then
      begin
        Result := pszPath;
        CoTaskMemFree( pszPath );
      end;
    end;
    { ====================================================================== }
    Mais SHGetKnownFolderPath et CoTaskMemFree sont inconnus de D7 ?

    Quelqu'un saurait il le faire ?

    Merci
    A+
    Charly

  2. #2
    Membre expert
    Avatar de Charly910
    Homme Profil pro
    Ingénieur TP
    Inscrit en
    Décembre 2006
    Messages
    2 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur TP
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 374
    Points : 3 152
    Points
    3 152
    Par défaut
    J'ai trouvé, la fonction est dans Shell32.dll :

    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
    Implementation
     
    Const
      FOLDERID_Downloads : TGUID = '{374DE290-123F-4565-9164-39C4925E467B}';
     
    Function SHGetKnownFolderPath(const rfid: TGuid; dwFlags: DWORD;
                 hToken: THandle; out ppszPath: PWideChar): HResult;
                stdcall; external 'Shell32.dll';
     
    Procedure TForm1.Button1Click(Sender: TObject);
    Var
      DownloadPath: LPWSTR;
    Begin
      if SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Downloads, 0, 0, DownloadPath)) then
            ShowMessage(DownLoadPath);
    End;
    A+
    Charly

  3. #3
    Membre actif Avatar de oneDev
    Homme Profil pro
    dilettant
    Inscrit en
    Mars 2019
    Messages
    214
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine Maritime (Haute Normandie)

    Informations professionnelles :
    Activité : dilettant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2019
    Messages : 214
    Points : 223
    Points
    223
    Par défaut
    Bonjour, tu peux utiliser simplement GetEnvironmentVariable('USERPROFILE') + '\DownLoads';

  4. #4
    Membre expert
    Avatar de Charly910
    Homme Profil pro
    Ingénieur TP
    Inscrit en
    Décembre 2006
    Messages
    2 374
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur TP
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 374
    Points : 3 152
    Points
    3 152
    Par défaut
    Oui, c'est vrai !
    Merci

    A+
    Charly

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 14/06/2007, 13h35
  2. [W10] Table mémoire vers fichier
    Par gbrion dans le forum WinDev
    Réponses: 2
    Dernier message: 13/02/2007, 08h37
  3. [w10]récupérer données page web
    Par minoltis dans le forum WinDev
    Réponses: 2
    Dernier message: 08/02/2007, 13h53
  4. [w10] Objets dans zone répétée
    Par Wells dans le forum WinDev
    Réponses: 9
    Dernier message: 16/01/2007, 09h51
  5. Migrer un projet W10 HF vers SQLServer Express : Possible ?
    Par Cazaux-Moutou-Philippe dans le forum WinDev
    Réponses: 1
    Dernier message: 02/12/2006, 15h45

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