您可以为此使用 Windows API 函数。要获取临时路径,您可以使用以下内容: 定义外部函数:
Kernel32.dll
Function: GetTempPathW
Return
DWORD
Parameters:
Number: DWORD ! nBufferLength [in] The size of the string buffer identified by lpBuffer, in TCHARs.
Receive String: LPWSTR ! lpBuffer [out] A pointer to a string buffer that receives the null-terminated string
像这样使用它:
Function: GetTempPath ! __exported
Description: WinAPI: This function retrieves the path of the directory designated for temporary files.
Returns
String:
Parameters
Local variables
String: sStrBuffer
Number: nBuffLen
Number: nNumChars
Actions
Set nBuffLen = 0
Call SalSetBufferLength( sStrBuffer, nBuffLen )
Set nBuffLen = GetTempPathW( nBuffLen, sStrBuffer )
Call SalSetBufferLength( sStrBuffer, nBuffLen * 2 )
Call GetTempPathW( nBuffLen, sStrBuffer )
If SalStrRightX( sStrBuffer, 1 ) != '\\'
Set sStrBuffer = sStrBuffer || '\\'
Return sStrBuffer
要检查您是否具有写入权限,只需在该文件夹中创建一个文件,然后将其删除。
这里有一些关于 Windows API 功能的更多信息:
https ://msdn.microsoft.com/de-de/library/windows/desktop/aa364992(v=vs.85).aspx