Thema: Word to PChar

Einzelnen Beitrag anzeigen

Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#27

Re: Word to PChar

  Alt 24. Jan 2008, 21:03
You don't need all that, it's all winapi:

// This is the version for NT Terminal Server, 2000, XP/2003 and Server 2008
function DateTimeString(DateTime: PFILETIME; lpBuffer: PWideChar): PWideChar;
stdcall;

// This is a wrapped for all OS versions
function DateTimeStringSafe(DateTime: PFILETIME; lpBuffer: PWideChar;
cchDest: SIZE_T): PWideChar; stdcall;

// This is the Vista version which takes an additional parameter with
// maximum buffer size (you have to set it)
function DateTimeStringVista(DateTime: PFILETIME; lpBuffer: PWideChar;
cchDest: SIZE_T): PWideChar; stdcall;

function DateTimeString; external utildll name 'DateTimeString';
function DateTimeStringVista; external utildll name 'DateTimeString';

function DateTimeStringSafe(DateTime: PFILETIME; lpBuffer: PWideChar;
cchDest: SIZE_T): PWideChar; stdcall;
begin
// Zero Memory
ZeroMemory(lpBuffer, cchDest * SizeOf(WCHAR));

// Are we running Vista?
if IsVista then
begin
// Vista version
Result := DateTimeStringVista(DateTime, lpBuffer, cchDest);
end
else begin
// Other OS's (including server 2008!)
Result := DateTimeString(DateTime, lpBuffer);
end;
end;
  Mit Zitat antworten Zitat