Guys I need some help here , can some shed some light on this issue  ?


I've got my own test dll with this function declared as an export


function GetCLSID(clsid:TGUID):Integer;stdcall;
begin
 clsid := TESTGUID;
 Result := S_OK;
end;

My testguid  = '{3F5A62E1-1112-1100-A075-CC7364CAE42A}'

and in my test application i have DLL call to this function

function GetGuid(var MyGuidTest: TGUID): Integer;
var
 Res:Integer;
begin
 Load;
 Res := PGetGuid(MyGuidTest);
 if Res = S_OK then
 begin
   Result := res;
 end;
 Unload;
end;

and PGetGuid is defined as

PGetGuid : TFunctionGetGUID; which TFunctionGetGUID = function (MyGuid:TGUID):Integer;StdCall;

I call this function above

MyGUid := GUID_NULL;
GetGuid(MyGuid);
LabelResult1.Caption := GUIDToString(MyGuid);


The Result of GetGuid is ALLWAYS GUID_NULL unless i change the DLL call to be like this

function GetCLSID(out clsid:TGUID):Integer;stdcall;
begin
 clsid := TESTGUID;
 Result := S_OK;
end;


This relates to Ipersist.GetClassID which needs to be defined like this

Function GetClassId(Out clsid:TClsId):HResult; StdCall;

but its defined as

Function GetClassId(clsid:TClsId):HResult; StdCall;

which is a show stopper in my app it work work because the DeskBand.DLL cant see which CSLID it is because the value never gets returned....


Delphian
----- Original Message ----- From: "Flávio Etrusco" <flavio.etru...@gmail.com> To: "Justin Smyth" <delph...@smythconsulting.net>; "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org>
Sent: Tuesday, April 06, 2010 9:56 AM
Subject: Re: [fpc-pascal] Poss FPC Bug.


On Mon, Apr 5, 2010 at 8:29 PM, Justin Smyth
<delph...@smythconsulting.net> wrote:
guys i've been working on a port of an application that uses the Com
IPersist Interface , one of its procedures seems to be wrong ,


Function GetClassId(clsid:TClsId):HResult; StdCall;

yet i believe it should be

Function GetClassId(out clsid:TClsId):HResult; StdCall

i've checked the MSDN and it says it should be returning a value -

its defined in C++ as

HRESULT GetClassID([out]  CLSID *pClassID);

pClassID [out]

A pointer to the location that receives the CLSID on return. The CLSID is a
globally unique identifier (GUID) that uniquely represents an object class
that defines the code that can manipulate the object's data.

Delphian

Ps if i change this in the code , its the FPC that needs to be re complied ?


I've fallen victim of the same 'trap' on a similar function. Arrays
are passed "by reference" automatically in 'stdcall' calling
convention.

Flávio



_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to