De-Referencing A Pointer
James Dunne
james.jdunne at gmail.com
Tue Mar 21 08:39:05 PST 2006
NoBoDy wrote:
> VB6 internally stores strings in UNICODE.
> When calling external functions VB6 uses stub to convert string to/from ANSI
> format.
>
> If you want to pass string from VB in Unicode use declaration like this:
> Declare Function findChar Lib "..." (ByVal t As LONG) As Long
>
> and call that function as:
> retValue = findChar(StrPtr("Some string"))
>
> this will pass pointer to UNICODE string to externall function findChar
>
>
> In article <dvp71g$hv1$1 at digitaldaemon.com>, James Dunne says...
>
>>Rory Starkweather wrote:
>>
>>>>void foo(dchar c) {}
>>>>void main()
>>>>{
>>>> foo('a');
>>>>}
>>>>
>>>>so you'll probably have no trouble there. :)
>>>>
>>>
>>>
>>>
>>>Thanks for the help. I'm still not sure how to get VB to send a dchar, but there
>>>are only a couple of possibilities. Unless you are suggesting that I pass it to
>>>D as a string and then use a conversion function on it.
>>>
>>>
>>
>>Actually you want to use wchar* at the D end from VB. VB sends
>>'Unicode' strings where each character is represented by two bytes.
>>This is the equivalent of a wchar* in D. char, wchar, and dchar in D
>>are all more-or-less interchangeable. The best way to get VB and D to
>>do string work together is this:
>>
>>Declare Function findChar Lib "..." (ByVal t As String) As Long
>>
>>export extern (Windows) int findChar(wchar* str) {
>> ...
>>}
>>
>>I'm not 100% sure if this works as I've had serious issues with VB6's
>>string handling in the past (especially in scenarios like this). I
>>think the trick is to initialize the string from VB's side and pass it
>>in to C/C++/D for them to modify it. I'll do some more research on this
>>and get you a better answer if I can.
>>
>>--
>>-----BEGIN GEEK CODE BLOCK-----
>>Version: 3.1
>>GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O
>>M--@ V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e
>>h>--->++ r+++ y+++
>>------END GEEK CODE BLOCK------
>>
>>James Dunne
>
>
>
Thanks! That helps a lot for me as well. So then am I still correct in
that D should work with a wchar* ?
BTW, do you have an MSDN reference for that info?
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O
M--@ V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e
h>--->++ r+++ y+++
------END GEEK CODE BLOCK------
James Dunne
More information about the Digitalmars-d-learn
mailing list