Announcement

Collapse
No announcement yet.

Getting Windows folder path

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting Windows folder path

    Hi All,
    How can I get the name of the windows main folder, as a text string?
    It's usually "c:\windows", but I've come across a few instances where other names are used:

    c:\winnt
    c:\win2000
    c:\winme
    c:\captkirk

    amongst others. Is there a relatively simple way to get this into a string, so that I can, for example, add the string "system32\" to the variable MyWinFolder$ to get a valid path?

    Thanks in advance to anyone that can help.

  • #2
    Code:
    'Uses API:   SHGetFolderPath
    
    #Compile Exe
    #Dim All
    #Include "win32api.inc"
    Function PBMain () As Long
        Dim strPath As Asciiz * %MAX_PATH
        SHGetFolderPath(0, %CSIDL_DESKTOPDIRECTORY, 0, 0, strPath)
    End Function
    
    '%CSIDL_DESKTOPDIRECTORY   DeskTop
    '%CSIDL_PROGRAM_FILES      Program Files
    '%CSIDL_SYSTEM             System folder
    '%CSIDL_WINDOWS            Windows directory 
    '%CSIDL_DESKTOP            <desktop>
    '%CSIDL_PROGRAMS           Start Menu\Programs
    '%CSIDL_PERSONAL           My Documents
    '%CSIDL_STARTUP            Start Menu\Programs\Startup
    '%CSIDL_MYDOCUMENTS        logical "My Documents" desktop icon
    '%CSIDL_DESKTOPDIRECTORY   <user name>\Desktop
    '%CSIDL_DRIVES             My Computer
    '%CSIDL_FONTS              windows\fonts

    Comment


    • #3
      Hi Gary,

      Thanks for that, it worked a treat. I'm getting better at this Windows stuff

      Cheers,
      Chris

      Comment

      Working...
      X