Thanks for the reply Rob. Apologies for the missing code. I don't have
Delphi running at the moment, but the code for the GetDescriptor
function looks something like this,

type
  TMeDIIntfForm = class (TForm);
  TMeDIIntfFormClass = class of TMeDIIntfForm;

function GetDescriptor(ID: PWideChar; var Descriptor: TDescriptor):
Integer;
  var
    AClass: TMeDIIntfFormClass;
begin
  if WideSameText(WideString(ID), TfrmOhmedaBiox.IntfID) then
  begin
    AClass := TfrmOhmedaBiox;
  end
  else
  begin
    AClass := nil;
  end;

  if Assigned(AClass) then
  begin
    Descriptor.ID := PWideChar(AClass.IntfID);
    Descriptor.Name := PWideChar(AClass.IntfName);
    Descriptor.Major := AClass.IntfMajorVersion;
    Descriptor.Minor := AClass.IntfMinorVersion;
    Descriptor.Flags := AClass.IntfFlags;
    Descriptor.Additional := PWideChar(AClass.IntfAdditionalInfo);
    Result := ERROR_CODE_SUCCESS;
  end
  else
  begin
    Result := ERROR_CODE_UNKNOWN_INTF;
  end;
end;

That's pretty much it, apart from some basic error handling that I've
left out for brevity. TfrmOhmedaBiox is a TMeDIIntfForm descendant,
which in turn is a TForm descendant. The functions IntfID, IntfName, and
IntfAdditionalInfo are all class functions that return WideStrings. It
sounds as though you might be right about the pointers to the
WideString's characters becoming invalid. However, the other fields are
okay still, or am I just getting lucky? If what you say is the case,
then any tips on how I should be adding those values to the members of
the record? There appear to be no overloaded versions of the StrPCopy,
etc functions that handle WideStrings and PWideChars.

Regards,
Darren
--
Darren Ferguson
Senior Software Engineer
Clinical Software Division
Medtel Australia
Adelaide, South Australia
 
-----Original Message-----

You forgot to show your code.

When you say the Descriptor record is "filled in," what does that mean
for the PWideChar fields? Exactly what wide character does each field
point to? If the character belongs to a WideString, then note that when
the WideString gets destroyed, any pointers to its characters become
invalid.

-- 
Rob
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to