Bonjour a tous,
Je voudrais passer un tableau de string à une dll, en gros :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
Private Declare Function MyFuntion_dll Lib "MyDll"(ByVal aFile as String, ByRef rTabId() as String) as long
Sub MyMacro
Dim i as long
Dim lFileName as String 
Dim lTabRetourString(10) as String
lFileName="C:\Users\.. \MyFile.csv"
i=MyFunction_dll(lFileName,lTabRetourString)
...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
int __stdcall MyFunction_dll(BSTR aStringFile, SAFEARRAY** rStringTabId)
{...}
mais dans la dll le type BSTR ne ramène pas du tout le string du VB et si je fais un SysAllocString(OLESTR("hello")) sur mon SAFEARRAY, l'execution crash.

D'après le tuto http://rp.developpez.com/vb/tutoriels/dll/#LXII il parle de récupérer le string VB dans la dll via un char*, ce qui marche en effet, mais dès qu'il sagit d'un tableau, le type de string ne peut être qu'un BSTR, ce qui ne marche pas du tout dans mon cas.
Par ailleurs je suis tombé là dessus sur le cite de microsoft http://support.microsoft.com/kb/145727/en-us :
Visual Basic, like Windows NT and Windows 2000, is based internally on the double-byte Unicode standard. However, Visual Basic assumes that the world outside of itself still uses the single-byte ANSI model. Any strings passed as parameters to an external function will be converted by Visual Basic from their internal Unicode representation to an ANSI representation before the call to the function is made. In the same way, all strings that return to Visual Basic from an external function are assumed to be in an ANSI representation, and Visual Basic will attempt to make the conversion to a Unicode representation for internal use. This behavior makes it impossible to call an external function that expects or returns a Unicode string in the same way as a function that deals only with ANSI strings.
Du coup y-at-il vraiment une solution pour passer un tableau de string vers une dll sans utiliser la techno COM. juste avec une dll compilée sous visual c++ ?
Merci pour votre aide