Re: Common Dialog questions
- From: "Randy Birch" <rgb_removethis@xxxxxxxx>
- Date: Mon, 9 May 2005 23:40:52 -0400
You can always retrieve the user's settings using the CSIDL constants ...
there is full listing under the CSIDL item at
http://vbnet.mvps.org/code/browse/index.html ; here's the basics of one
method with using these values:
Option Explicit
Private Const MAX_LENGTH = 260
Private Const S_OK = 0
Private Const SHGFP_TYPE_CURRENT = &H0
Private Declare Function SHGetFolderPath _
Lib "shfolder.dll" Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwReserved As Long, _
ByVal lpszPath As String) As Long
Private Sub Command1_Click()
Const CSIDL_DESKTOPDIRECTORY = &H10
Debug.Print GetFolderPath(CSIDL_DESKTOPDIRECTORY)
End Sub
Private Function GetFolderPath(CSIDL As Long) As String
Dim sPath As String
Dim sTmp As String
'fill pidl with the specified folder item
sPath = Space$(MAX_LENGTH)
If SHGetFolderPath(Me.hWnd, CSIDL, 0&, SHGFP_TYPE_CURRENT, sPath) = S_OK
Then
sTmp = Left$(sPath, InStr(sPath, Chr$(0)) - 1)
End If
GetFolderPath = sTmp
End Function
> C:\Documents and Settings\birchr\Desktop
There's also a way to directly set the directory in the common dialog by
specifying the actual registry value (CLSID) for the particular item.
Unfortunately though, while I can locate the Desktop value, this refers to
the virtual desktop folder and not that of the file system, so navigation
using that value will not work. The others listed here, however, do,
depending of course on the OS for some of the later items.
Private Sub Command2_Click()
With CommonDialog1
' .InitDir = "::{1f4de370-d627-11d1-ba4f-00a0c91eedba}" 'Computer
Search Results Folder
' .InitDir = "::{645FF040-5081-101B-9F08-00AA002F954E}" 'Recycle Bin
' .InitDir = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" 'my docs
' .InitDir = "::{e17d4fc0-5564-11d1-83f2-00a0c90dc849}" 'Search
Results Folder
' .InitDir = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" 'my computer
' .InitDir = "::{7007ACC7-3202-11D1-AAD2-00805FC1270E}" 'Network
Connections
' .InitDir = "::{D20EA4E1-3957-11d2-A40B-0C5020524152}" 'fonts
' .InitDir = "::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}" 'Scheduled
Tasks
' .InitDir = "::{E211B736-43FD-11D1-9EFB-0000F8757FCD}" 'Scanners &
Cameras
' .InitDir = "::{208D2C60-3AEA-1069-A2D7-08002B30309D}" 'my network
places
.InitDir = "::{00021400-0000-0000-C000-000000000046}" 'desktop
(virtual, not disk)
.ShowOpen
End With
End Sub
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------
"Steve Easton" <admin@xxxxxxxxxxxxx> wrote in message
news:uFuTpNQVFHA.3280@xxxxxxxxxxxxxxxxxxxxxxx
: Using a getfile.ShowOpen common dialog:
:
: 1. Is there a common string I can use for getfile.InitDir that will open
the desktop in both 9x and
: 2K / XP
: I know that: C:Windows\Desktop will do it in 9x, and
%UserProfile%\Desktop will do it in 2K / XP.
: Is there something common to both??
:
: 2. Is there a way to change the text on the Open button so that the open
button reads: Add, Lock or
: Unlock depending upon which function the user is performing??
:
: As always, many thanks in advance.
:
: ;-)
:
: --
: Steve Easton
: Microsoft MVP FrontPage
: 95isalive
: This site is best viewed............
: .......................with a computer
:
:
.
- Follow-Ups:
- Re: Common Dialog questions
- From: Sam Hobbs
- Re: Common Dialog questions
- References:
- Common Dialog questions
- From: Steve Easton
- Common Dialog questions
- Prev by Date: Re: Common Dialog questions
- Next by Date: Re: Common Dialog questions
- Previous by thread: Re: Common Dialog questions
- Next by thread: Re: Common Dialog questions
- Index(es):
Relevant Pages
|