[AccessD] Windows Temporary Directory

Stuart McLachlan stuart at lexacorp.com.pg
Tue Aug 16 08:07:59 CDT 2011


Oops, sorry. I left that out when during the copy/paste. 

Just add:
CONST MAX_PATH = 260
at the top of the public module.

It's a legacy value base on the path length limitation in Fat32  and is still used in many API 
header/include files.     

If you are only using it on NTFS volumes, you can use a much larger value here if there is a 
chance that the Temp directory path is longer than that.

-- 
Stuart

On 16 Aug 2011 at 5:39, Dale Kalsow wrote:

> OK - thanks,  One question how and is MAX_PATH defined?
>  
> Dale
> 
> From: Stuart McLachlan <stuart at lexacorp.com.pg>
> To: Access Developers discussion and problem solving
> <accessd at databaseadvisors.com> Sent: Monday, August 15, 2011 4:16 PM
> Subject: Re: [AccessD] Windows Temporary Directory
> 
> I put this in a Public module:
> 
> <code>
> Private Declare Function GetTempPath Lib "kernel32" Alias
> "GetTempPathA" _ (ByVal nBufferLength As Long, ByVal lpBuffer As
> String) As Long
> 
> 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
> </code>
> 
> and then use it like this:
> 
> <code>
> 'build full path/file name and delimit with qiuotes to
> 'allow for spaces in path of file
> 
> strQ = chr$(34)
> strFile = "myfile.txt"
> strFile = strQ & Tempdir()  & strFile & strQ
> 
> 'Now open file from a Shell
> strShell = "Notepad.exe " &  & strFile
> retval = Shell(strShell)
> </code>
> 
> -- 
> Stuart
> On 15 Aug 2011 at 8:07, Dale Kalsow wrote:
> 
> > Good Morning,
> >  
> > I am trying to write a file into the windows temporary directory but
> > am having issues referencing it.  Could someone tell me the propery
> > way to reference the temp direcory when using the RetVal = Shell()
> > command.   Thanks!   Dale -- AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd Website:
> > http://www.databaseadvisors.com
> > 
> 
> 
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> -- 
> 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