1

これまでのところ、Typelib を使用して Euphoria DLL との間で Unicode 文字列 (bSTR) を渡す方法を理解しました。これまでのところ、BSTR の配列を作成して返す方法がわかりません。

私がこれまでに持っているコード ( includeEuCOM 自体と Win32lib の一部の s とともに):

global function REALARR()
  sequence seq
  atom psa
  atom var
  seq = { "cat","cow","wolverine" }
  psa = create_safearray( seq, VT_BSTR )
  make_variant( var, VT_ARRAY + VT_BSTR, psa )
  return var
end function

タイプライブラリの一部は次のとおりです。

  [
     helpstring("get an array of strings"), 
     entry("REALARR")
  ] 
  void __stdcall REALARR( [out,retval] VARIANT* res );

VB6 のテスト コードは次のとおりです。

...
Dim v() as String
V = REALARR()
...

これまでに取得できたのは、DLL からのエラー「0」だけです。何か案は?誰?

4

3 に答える 3

1

関数を使用する必要がありcreate_safearray()ます。ユーティリティの下に文書化されています(隠されていますか?)。基本的に、BSTR ポインターをシーケンスに入れて、次のように渡しますcreate_safearray()

sequence s, bstrs
s = {"A", "B"}
bstrs = {}
for i = 1 to length(s) do
    bstrs &= alloc_bstr( s[i] )
end for

atom array
array = create_safearray( bstrs, VT_BSTR )

...

destroy_safearray( array )
于 2009-11-04T18:43:49.587 に答える
0

さて、var初期化されていません。ルーチンがまだクラッシュするので、それは問題ではありません。それにもかかわらず、人は

var = allocate( 16 )

make_variant の直前

于 2008-10-20T15:42:03.973 に答える
0

Euphoria の人々とはフォーラムを通じて連絡を取り合っており、ここまでたどり着きました。ルーチンが make_variant 行で失敗しています。私はそれ以上のことを理解していませんし、彼らもそうではありません。

global function REALARR() 
  atom psa 
  atom var 
  atom bounds_ptr 
  atom dim 
  atom bstr 
  object void 

  dim = 1 
  bounds_ptr = allocate( 8 * dim ) -- now figure out which part is Extent and which is LBound 
  poke4( bounds_ptr, { 3, 0 } ) -- assuming Extent and LBound in that order 

  psa = c_func( SafeArrayCreate, { VT_BSTR, 1, bounds_ptr } ) 

  bstr = alloc_bstr( "cat" ) 
  poke4( bounds_ptr, 0 ) 
  void = c_func( SafeArrayPutElement, {psa, bounds_ptr, bstr}) 
  free_bstr( bstr ) 

  bstr = alloc_bstr( "cow" ) 
  poke4( bounds_ptr, 1 ) 
  void = c_func( SafeArrayPutElement, {psa, bounds_ptr, bstr}) 
  free_bstr( bstr ) 

  bstr = alloc_bstr( "wolverine" ) 
  poke4( bounds_ptr, 2 ) 
  void = c_func( SafeArrayPutElement, {psa, bounds_ptr, bstr}) 
  free_bstr( bstr ) 

  make_variant( var, VT_ARRAY + VT_BSTR, psa )  
  return var 
end function 
于 2008-10-17T07:15:11.317 に答える