Re: SafeArray Locked error - WeOnlyDo Discussion board

Re: SafeArray Locked error (General questions)

by forthyen, Tuesday, January 15, 2008, 02:31 (6161 days ago) @ woddrazen

Yes, I get 1.2.1.43 and modify it as follows. Is it DEPLHI7's problem ? I use delphi 7.0(build 4.453). Is this code error ? Would you please check it ? Thanks!

procedure TForm1.Button4Click(Sender: TObject);
var psaiNew : PSafeArray;
aDim : array [0..0] of TSafeArrayBound;
arraydata : Pointer;
v : Variant;
n : integer;
data : pointer;
buf : array [1..1024] of char;
begin
ShowMessage(wodVPN1.Version);
data := @buf;
n := 500;
aDim[0].lLbound := 1;
aDim[0].cElements := n;
psaiNew := SafeArrayCreate(VT_UI1, 1, aDim);
psaiNew.cLocks := 0;
if psaiNew <> nil then begin
SafeArrayAccessData(psaiNew, arraydata);
Move(data^,arraydata^,n);
SafeArrayUnaccessData(psaiNew);
TVariantArg(v).vt := VT_ARRAY or VT_UI1;
TVariantArg(v).parray := psaiNew;
wodVPN1.SendData(v, FALSE); // not reliable
end;

// wodVPN1.SendText(Edit5.Text, True);
end;


Complete thread: