|
-
May 16th, 2000, 01:45 AM
#1
Thread Starter
Member
hi.
how can i get the desktop path on the client computers.
( even on nt or windows with more than one user.)
-
May 16th, 2000, 03:57 AM
#2
To get the Desktop folder path, use this:
Code:
Private Const CSIDL_DESKTOP = &H0
Private Const MAX_PATH = 255
Private Declare Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hwndOwner As Long, ByVal nFolder As Integer, ppidl As Long) As Long
Private Declare Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal szPath As String) As Long
Public Function GetDesktopFolderPath(ByVal pHwnd As Long) As String
Dim lReturn As Long
Dim lPidl As Long
Dim lPath As Long
Dim sPath As String
sPath = Space$(MAX_PATH)
lReturn = SHGetSpecialFolderLocation(pHwnd, CSIDL_DESKTOP, lPidl) ' Get lPidl for Id...
If lReturn = 0 Then ' If success is 0
lReturn = SHGetPathFromIDList(lPidl, sPath) ' Get Path from Item Id List
If lReturn = 1 Then ' If success is 1
sPath = Left(sPath, InStr(sPath, vbNullChar) - 1) ' Fix path string
GetDesktopFolderPath = sPath ' Return Favorite path
End If
End If
End Function
Then you can call this function to get the path of the desktop folder:
Dim strPath As String
strPath = GetDesktopFolderPath(Me.Hwnd)
strPath now holds the path to the Desktop.
-
May 16th, 2000, 04:10 AM
#3
Or you could just check if one exists.
Public Function DirExists(ByVal strDirName As String) As Integer
Dim strDummy As String
On Error Resume Next
If Right$(strDirName, 1) <> "\" Then
strDirName = strDirName & "\"
End If
strDummy = Dir$(strDirName & "*.*", vbDirectory)
DirExists = Not (strDummy = vbNullString)
Err = 0
End Function
If DirExists("C:\Windows\Desktop\") Then
Msgbox "Desktop Folder exists"
Else
Msgbox "Desktop Folder doesn't exists! Where the hell could it be?"
End If
-
May 16th, 2000, 08:24 AM
#4
Using Dir function you have to be absolutely sure that windows directory is installed under C:\Windows.
Where using APIs you don'thave to care where it is installed under.
-
May 16th, 2000, 02:26 PM
#5
Fanatic Member
Very true.
Winnt has the desktop in the profiles\username dir and win2k has bits of it in different places.
Definately use the API
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|