views:

265

answers:

1

I have a simple COM dll with a method that takes two strings. In the type library editor of delphi these strings are defined as LPSTR. This translates to PChar in the TLB file. When upgrading from D2007 to D2009 this became a problem since PChar now has changed from PAnsiChar to PWideChar (it still becomes PChar in the TLB file when it is generated from the ridl file). And the interface needs to compatible with the previous one...

Is there a way to get PAnsiChar as type in the TLB file so that it corresponds to the previous declaration in D2007?

+2  A: 

You can modify the generated code yourself. The easiest way is probably to redeclare PChar:

type
  PChar = PAnsiChar;

on top of the generated unit.

Or just search and replace all occurencies (where needed) of PChar with PAnsiChar.

BTW, it's a strange COM DLL since it's not Automation-compatible. Normally, BSTR (WideString in Delphi) is used for strings in COM.

TOndrej
You're right, it is a strange interface... The best way is probably to make a new version of it (it is only used internally by our own SW).
ajob