Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-04

Poss FPC Bug.

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Justin Smyth

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 ?

Flávio Etrusco
to Justin Smyth
Justin Smyth wrote 26 lines
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

Justin Smyth
to Flávio Etrusco

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

Earlier message 44 lines
----- Original Message ----- From: "Flávio Etrusco" To: "Justin Smyth" ; "FPC-Pascal users discussions" 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 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