[AccessD] A Matter of Killing

Rocky Smolin rockysmolin at bchacc.com
Sun Aug 16 17:09:48 CDT 2009


Into the library it goes! Desktop is never easy to find.

Rocky
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan
Sent: Sunday, August 16, 2009 3:02 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] A Matter of Killing

On 16 Aug 2009 at 14:26, Rocky Smolin wrote:

> I could get around even that possibility by changing gstrBackEndPath 
> to gstrFrontEndPath - another handy global I keep around for just such 
> application.  I'll have to ask the user what they prefer. User's in 
> Bahrain, BTW - another 'remote' location.
> 
> Rocky

Depending on whether or not they need to keep the file afterwards, other
possibilities are to write the file into the users "Documents", "Desktop" or
"Temp" directory - or even the users "AppData".

Here's some useful functions if you want to go down that track.  Desktop()
is a sample. You can create similar functions for the other locations by
substituting the appropriate CSIDL_xxx in the function.

Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long Private
Declare Function SHGetSpecialFolderLocation _
    Lib "shell32" (ByVal hwnd As Long, _
    ByVal nFolder As Long, ppidl As Long) As Long Private Declare Function
SHGetPathFromIDList _
    Lib "shell32" Alias "SHGetPathFromIDListA" _
    (ByVal Pidl As Long, ByVal pszPath As String) As Long Private Declare
Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)
       
Const MAX_PATH = 260
Const NOERROR = 0
Const CSIDL_DESKTOPDIRECTORY = &H0010 
Const CSIDL_PERSONAL =  &H0005   'Documents Directory	
Const %CSIDL_APPDATA = &H001a    '<user name>\Application Data

Public Function TempDir() As String
Dim strPath As String
strPath = Space(MAX_PATH)
GetTempPath Len(strPath), strPath
TempDir = Left(strPath, InStr(1, strPath, vbNullChar) - 1) End Function

Public Function Desktop() As String
Dim lngPidlFound As Long
Dim lngFolderFound As Long
Dim lngPidl As Long
Dim strPath As String
strPath = Space(MAX_PATH)
lngPidlFound = SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY,
lngPidl) If lngPidlFound = NOERROR Then
    lngFolderFound = SHGetPathFromIDList(lngPidl, strPath)
    If lngFolderFound Then
        Desktop = Left$(strPath, _
            InStr(1, strPath, vbNullChar) - 1) & "\"
    End If
End If
CoTaskMemFree lngPidl
End Function


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list