Empty string becomes null when passed from Delphi to C# as a function argument

后端 未结 4 408
南笙
南笙 2021-01-14 14:43

I have a native Delphi exe which calls into C# dll via COM interop. Here\'s the simplest case which demonstrate this issue:

Delphi:

IClass1 = interfa         


        
4条回答
  •  孤独总比滥情好
    2021-01-14 15:26

    In Delphi, AnsiString, UnicodeString, and WideString values are represented by a nil pointer when they are empty. COM uses BSTR for strings. Delphi wraps BSTR with WideString. So there is no way to pass an "empty" non-nil string to a COM method that takes a WideString as a parameter, it will be nil instead.

提交回复
热议问题