Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 16496, Error in OleServer

by Alex Majorov Email: lexa@megasoft.ru


Error in function TServerEventDispatch.Invoke on D6
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 1.0  to 6.0 142 downloads
Copyright: No significant restrictions


Size: 3,077 bytes
Updated on Sun, 02 Sep 2001 10:23:26 GMT
Originally uploaded on Thu, 30 Aug 2001 01:46:01 GMT
SHA1 Hash: 59105EB5EB04CE610A1CA62BBAAAFBCB6D8C933E
MD5 Hash: A5FAAAFA24DC3384629D5D8426330C22

    Explore the files in this upload

Description
Problem.
When function TServerEventDispatch.Invoke passing parameters in FServer.InvokeEvent(DispID, VarArray) it's changing order of parameter on preorder and when pass it in serverevent.
{
for I := Low(VarArray) to High(VarArray) do
VarArray[High(VarArray)-I] := OleVariant(TDispParams(Params).rgvarg^[I]);
// Invoke Server proxy class
if FServer <> nil then FServer.InvokeEvent(DispID, VarArray);
}
But when you doing Import type library, D6 again changing order, and in result we have over again postorder.
{
rocedure TServerName.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
begin
case DispID of
-1: Exit; // DISPID_UNKNOWN
1: if Assigned(FOnEvent) then
FOnReceiveMail(Self, Params[1] {OleVariant}, Params[0]{LongWord});
end;
end;//It's code generated by D6
}
This problem can be solve in this way

function TServerEventDispatch.Invoke(DispID: Integer; const IID: TGUID;
LocaleID: Integer; Flags: Word; var Params;
VarResult, ExcepInfo, ArgErr: Pointer): HResult;
var
ParamCount, I: integer;
VarArray : TVariantArray;
begin
// Get parameter count
ParamCount := TDispParams(Params).cArgs;

// Set our array to appropriate length
SetLength(VarArray, ParamCount);

// Copy over data
{Original version
for I := Low(VarArray) to High(VarArray) do
VarArray[High(VarArray)-I] := OleVariant(TDispParams(Params).rgvarg^[I]); }
{My version :) Ãíóñíûé õàê :)))}
for I := Low(VarArray) to High(VarArray) do
VarArray[I-Low(VarArray)] := OleVariant(TDispParams(Params).rgvarg^[I]);


// Invoke Server proxy class
if FServer <> nil then FServer.InvokeEvent(DispID, VarArray);

// Copy data back
for I := Low(VarArray) to High(VarArray) do
OleVariant(TDispParams(Params).rgvarg^[I]) := VarArray[I-Low(VarArray)];

// Clean array
SetLength(VarArray, 0);

// Pascal Events return 'void' - so assume success!
Result := S_OK;
end;

Server Response from: ETNACDC03