9,62 → 9,36 |
uses |
Windows, Classes, UD2_PluginIntf; |
|
(* |
function WritePascalStringToPointerA(lpDestination: LPSTR; cchSize: DWORD; |
stSource: AnsiString): UD2_STATUSCODE; |
*) |
function UD2_WritePascalStringToPointerW(lpDestination: LPWSTR; cchSize: DWORD; |
stSource: WideString): UD2_STATUS; |
|
function WritePascalStringToPointerW(lpDestination: LPWSTR; cchSize: DWORD; |
stSource: WideString): UD2_STATUSCODE; |
function UD2_WriteStringListToPointerW(lpDestination: LPWSTR; cchSize: DWORD; |
slSource: TStrings): UD2_STATUS; |
|
(* |
function WriteStringListToPointerA(lpDestination: LPSTR; cchSize: DWORD; |
slSource: TStrings): UD2_STATUSCODE; |
*) |
|
function WriteStringListToPointerW(lpDestination: LPWSTR; cchSize: DWORD; |
slSource: TStrings): UD2_STATUSCODE; |
|
implementation |
|
uses |
Math; |
|
(* |
function WritePascalStringToPointerA(lpDestination: LPSTR; cchSize: DWORD; |
stSource: AnsiString): UD2_STATUSCODE; |
function UD2_IsMultiLineW(s: WideString): boolean; |
var |
cchSource: DWORD; |
i: integer; |
c: WideChar; |
begin |
if cchSize = 0 then |
for i := 1 to Length(s) do |
begin |
result := STATUS_INVALID_ARGS; |
c := s[i]; |
if c = UD2_MULTIPLE_ITEMS_DELIMITER then //if (c = #10) or (c = #13) then |
begin |
Result := true; |
Exit; |
end; |
if stSource = '' then |
begin |
ZeroMemory(lpDestination, SizeOf(AnsiChar)); |
result := STATUS_OK; |
end |
else |
begin |
CopyMemory(lpDestination, @stSource[1], cchSize*SizeOf(AnsiChar)); |
cchSource := Cardinal(Length(stSource)); |
if cchSource >= cchSize then |
begin |
result := STATUS_BUFFER_TOO_SMALL; |
ZeroMemory(lpDestination+(cchSize-1)*SizeOf(AnsiChar), SizeOf(AnsiChar)); |
end |
else |
begin |
result := STATUS_OK; |
end; |
Result := false; |
end; |
end; |
*) |
|
function WritePascalStringToPointerW(lpDestination: LPWSTR; cchSize: DWORD; |
stSource: WideString): UD2_STATUSCODE; |
function UD2_WritePascalStringToPointerW(lpDestination: LPWSTR; cchSize: DWORD; |
stSource: WideString): UD2_STATUS; |
var |
cchSource: DWORD; |
cchCopy: DWORD; |
71,7 → 45,7 |
begin |
if cchSize = 0 then |
begin |
result := UD2_STATUS_INVALID_ARGS; |
result := UD2_STATUS_ERROR_INVALID_ARGS; |
Exit; |
end; |
|
81,38 → 55,21 |
begin |
CopyMemory(lpDestination, @stSource[1], cchCopy*SizeOf(WideChar)); |
end; |
ZeroMemory(lpDestination+cchCopy*SizeOf(WideChar), SizeOf(WideChar)); |
lpDestination[cchCopy] := #0; |
|
if cchSource >= cchSize then |
begin |
result := UD2_STATUS_BUFFER_TOO_SMALL; |
end |
result := UD2_STATUS_ERROR_BUFFER_TOO_SMALL |
else if stSource = '' then |
result := UD2_STATUS_NOTAVAIL_UNSPECIFIED |
else if UD2_IsMultiLineW(stSource) then |
result := UD2_STATUS_OK_MULTILINE |
else |
begin |
result := UD2_STATUS_OK; |
result := UD2_STATUS_OK_SINGLELINE; |
end; |
end; |
|
(* |
function WriteStringListToPointerA(lpDestination: LPSTR; cchSize: DWORD; |
slSource: TStrings): UD2_STATUSCODE; |
function UD2_WriteStringListToPointerW(lpDestination: LPWSTR; cchSize: DWORD; |
slSource: TStrings): UD2_STATUS; |
var |
stSource: AnsiString; |
i: integer; |
begin |
stSource := ''; |
for i := 0 to slSource.Count-1 do |
begin |
if i > 0 then stSource := stSource + UD2_MULTIPLE_ITEMS_DELIMITER; |
stSource := stSource + slSource.Strings[i]; |
end; |
result := WritePascalStringToPointerA(lpDestination, cchSize, stSource); |
end; |
*) |
|
function WriteStringListToPointerW(lpDestination: LPWSTR; cchSize: DWORD; |
slSource: TStrings): UD2_STATUSCODE; |
var |
stSource: WideString; |
i: integer; |
begin |
122,7 → 79,7 |
if i > 0 then stSource := stSource + UD2_MULTIPLE_ITEMS_DELIMITER; |
stSource := stSource + slSource.Strings[i]; |
end; |
result := WritePascalStringToPointerW(lpDestination, cchSize, stSource); |
result := UD2_WritePascalStringToPointerW(lpDestination, cchSize, stSource); |
end; |
|
end. |