` Printed Icetips Article

Icetips Article



Par2: Current User Desktop Folder
2013-06-27 -- Dave Nichols
 
!Get the users or global Desktop path

!gxGetDesktopPath(BYTE=0),STRING
!                 !       !the Desktop path or '' if can't find it
!                 !iff TRUE get the common desktop (all users), else 
just this users

gxGetDesktopPath FUNCTION(Common)

CSIDL:CREATE                   EQUATE(8000h)
CSIDL:COMMON_DESKTOPDIRECTORY  EQUATE(0019h)
CSIDL:DESKTOPDIRECTORY         EQUATE(0010h)

DesktopPath          CSTRING(261),AUTO
PIDL                 LONG
FolderId             LONG

   CODE

   IF Common
     FolderId = CSIDL:COMMON_DESKTOPDIRECTORY
   ELSE
     FolderId = CSIDL:DESKTOPDIRECTORY
   END

   IF SHGetSpecialFolderLocation(0,FolderId+CSIDL:CREATE,PIDL) = 0
     IF SHGetPathFromIDList(PIDL,DesktopPath) = 1
       !OK
     ELSE
       DesktopPath = ''
     END
     CoTaskMemFree(PIDL)
   ELSE
     DesktopPath = ''
   END

   RETURN Clip(DesktopPath)

The windoze prototypes are:

SHGetSpecialFolderLocation(LONG,LONG,*LONG),LONG,PASCAL,RAW,NAME('SHGetSpecialFolderLocation')
SHGetPathFromIDList(LONG,*CSTRING),BYTE,PASCAL,RAW,NAME('SHGetPathFromIDList')
CoTaskMemFree(LONG),PASCAL,RAW,NAME('CoTaskMemFree')

and

gxGetDesktopPath(BYTE=0),STRING



Printed November 21, 2024, 6:46 am
This article has been viewed/printed 35315 times.