Darren Ferguson wrote:
> type
>   TDescriptor = packed record
>     ID: PWideChar;
>     Name: PWideChar;
>     Major: Integer;
>     Minor: Integer;
>     Flags: Integer;
>     Additional: PWideChar;
>   end;
> 
> I have an exported function from a DLL I've written that is declared as
> follows,
> 
> function GetDescriptor(ID: PWideChar; var Descriptor: TDescriptor):
> Integer;
> 
> This function simply looks up the appropriate values based on the ID
> parameter, fills in the members of the Descriptor parameter, and returns
> an integer value to indicate success or failure. This all works fine for
> the most part. The calling application asks for the descriptor for a
> given ID and it gets it back with everything correctly filled in. 
> 
> However, when the ID is less than 5 characters, it leaves the
> GetDescriptor function with the ID member properly set in the Descriptor
> parameter, but when it returns to the calling application the ID member
> is complete garbage. All other values are correct and ID's longer than 6
> characters are fine also. Note that I do not use the ID parameter to
> fill in the ID member of the Descriptor parameter.
> 
> Does anyone have any ideas?

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

Reply via email to