1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
unit Utils;
interface
uses windows;
function SaveTemporaryW(ptr:pointer;size:dword;ext:PWideChar=nil):pWideChar;
function SaveTemporary (ptr:pointer;size:dword;ext:PAnsiChar=nil):PAnsiChar;
implementation
uses common,io;
function SaveTemporaryW(ptr:pointer;size:dword;ext:PWideChar=nil):pWideChar;
var
buf,buf1:array [0..MAX_PATH-1] of WideChar;
f:THANDLE;
begin
GetTempPathW(MAX_PATH,buf);
GetTempFileNameW(buf,'wat',GetCurrentTime,buf1);
ChangeExtW(buf1,ext);
f:=ReWrite(buf1);
BlockWrite(f,pByte(ptr)^,size);
CloseHandle(f);
StrDupW(result,buf1);
end;
function SaveTemporary(ptr:pointer;size:dword;ext:PAnsiChar=nil):PAnsiChar;
var
buf,buf1:array [0..MAX_PATH-1] of AnsiChar;
f:THANDLE;
begin
GetTempPathA(SizeOf(buf),buf);
GetTempFileNameA(buf,'wat',GetCurrentTime,buf1);
ChangeExt(buf1,ext);
f:=ReWrite(buf1);
BlockWrite(f,pByte(ptr)^,size);
CloseHandle(f);
StrDup(result,buf1);
end;
end.
|