Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do you get the path to the WIndows desktop?

How do you get the path to the WIndows desktop?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Terry ONolley
    wrote on last edited by
    #1

    How do you form the filepath string to indicate you want to save a file to the desktop? I know "C:\\FOLDER\\FILE.TXT" but what is the path to the desktop? A client asked me to make a simple change to a downloadable web installer tool I wrote. It used to have a File...Save As dialog and they wanted me to change it to automatically save to the dektop. No problem! I said I'd do it for free. Delete the common dialog code, change the CFile.SetFilePath code from CCommonDialog.GetPathName to............ what? What is that magical cobination of ascii characters that tells my app to save to the desktop? TIA!


    //placeholder for witty verbiage

    Y P 2 Replies Last reply
    0
    • T Terry ONolley

      How do you form the filepath string to indicate you want to save a file to the desktop? I know "C:\\FOLDER\\FILE.TXT" but what is the path to the desktop? A client asked me to make a simple change to a downloadable web installer tool I wrote. It used to have a File...Save As dialog and they wanted me to change it to automatically save to the dektop. No problem! I said I'd do it for free. Delete the common dialog code, change the CFile.SetFilePath code from CCommonDialog.GetPathName to............ what? What is that magical cobination of ascii characters that tells my app to save to the desktop? TIA!


      //placeholder for witty verbiage

      Y Offline
      Y Offline
      Yawar Maajed
      wrote on last edited by
      #2

      use ::SHGetSpecialFolderLocation or SHGetSpecialFolderPath function. with folder parameter as CSIDL_COMMON_DESKTOPDIRECTORY (for all users) or as CSIDL_DESKTOP (for currently logged in user). Functions are declared in Shlobj.h /yawar

      T 1 Reply Last reply
      0
      • T Terry ONolley

        How do you form the filepath string to indicate you want to save a file to the desktop? I know "C:\\FOLDER\\FILE.TXT" but what is the path to the desktop? A client asked me to make a simple change to a downloadable web installer tool I wrote. It used to have a File...Save As dialog and they wanted me to change it to automatically save to the dektop. No problem! I said I'd do it for free. Delete the common dialog code, change the CFile.SetFilePath code from CCommonDialog.GetPathName to............ what? What is that magical cobination of ascii characters that tells my app to save to the desktop? TIA!


        //placeholder for witty verbiage

        P Offline
        P Offline
        palbano
        wrote on last edited by
        #3

        SHGetSpecialFolderLocation()

        "No matter where you go, there your are." - Buckaroo Banzai

        -pete

        1 Reply Last reply
        0
        • Y Yawar Maajed

          use ::SHGetSpecialFolderLocation or SHGetSpecialFolderPath function. with folder parameter as CSIDL_COMMON_DESKTOPDIRECTORY (for all users) or as CSIDL_DESKTOP (for currently logged in user). Functions are declared in Shlobj.h /yawar

          T Offline
          T Offline
          Terry ONolley
          wrote on last edited by
          #4

          Fantastic Yawar! I googled, I searched but I never would have thought to look there :) This did the trick. Thanks.


          //placeholder for witty verbiage

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups