Date: 02-16-2022
Return to Index
created by gbSnippets
'Windows API can identify folders set aside for special purposes
'Primary Code:
Dim strPath As Asciiz * %MAX_PATH
SHGetFolderPath(0, %CSIDL_DESKTOPDIRECTORY, 0, 0, strPath)
'Here are a few of the equates to retrieve the corresponding directory:
'See the Win32API.INC file for additional equates.
%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
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
Local sPath As Asciiz * %MAX_PATH, temp$
SHGetFolderPath(0, %CSIDL_DeskTopDirectory, 0, 0, sPath) : temp$ = temp$ + sPath + $crlf
SHGetFolderPath(0, %CSIDL_Program_Files, 0, 0, sPath) : temp$ = temp$ + sPath + $crlf
SHGetFolderPath(0, %CSIDL_System, 0, 0, sPath) : temp$ = temp$ + sPath + $crlf
SHGetFolderPath(0, %CSIDL_Windows, 0, 0, sPath) : temp$ = temp$ + sPath + $crlf
SHGetFolderPath(0, %CSIDL_DeskTop, 0, 0, sPath) : temp$ = temp$ + sPath + $crlf
SHGetFolderPath(0, %CSIDL_Programs, 0, 0, sPath) : temp$ = temp$ + sPath + $crlf
SHGetFolderPath(0, %CSIDL_Personal, 0, 0, sPath) : temp$ = temp$ + sPath + $crlf
SHGetFolderPath(0, %CSIDL_Startup, 0, 0, sPath) : temp$ = temp$ + sPath + $crlf
SHGetFolderPath(0, %CSIDL_Startup, 0, 0, sPath) : temp$ = temp$ + sPath + $crlf
MsgBox temp$
End If
End Function
'gbs_00248
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm