2011-12-08 25 views
6

我想製作一個界面,但我不知道什麼。OleVariant是否可用於DLL proc中的out參數?

OleVariant包含「標準」字符串的「標準」 - 傳遞和返回?

function Any(Input : OleVariant; out Output : OleVariant) : integer; stdcall; 

另一方面可能是.NET,C#或C++或Delphi。

因此,他們可以在OleVariant回一些「字符串」結果沒有我傳遞預定義的大小的緩衝區結果?

+1

使用WideString傳遞字符串變量並節省您的麻煩。看看[這裏](http://stackoverflow.com/questions/8414972/delphis-sharemem-when-it-is-not-needed)一些額外的指針 –

+1

OleVariant將*不*包含一個「標準」字符串(如果標準字符串是德爾福字符串)。將字符串分配給OleVariant時,該字符串將轉換爲「WideString」。 –

回答

11

是的,OleVariant是完全安全的。你會看到它在與Delphi分發的COM相關單元中使用,例如ActiveX,ComSvcs和MSXML。標準的Windows API單元使用它,所以你也可以。

如果你總是期待一個字符串,那麼你應該更喜歡WideString。它相當於Windows BSTR類型。