Board index » cppbuilder » WideStrings and BSTR broken in BCB4 COM? Help?

WideStrings and BSTR broken in BCB4 COM? Help?

I am having some trouble with BCB4 COM work, coming from Delphi4 and VC++6.
There seems to be something wong with the handling of widestrings in UNICODE
mode.

If I wizard-build a trivial Automation server, with a simple method or
(even) no methods, and I try to compile it, it starts throwing const char*
to const wchar_t* conversion errors in utilcls.h, atlvcl.h and other core
includes. If I remove the UNICODE definition in the project conditionals, it
compiles OK. This is with NO manually generated code in the project.

Test case: Just start a new app, add an ActiveX automation object, make sure
the project defines UNICODE, save it, compile it. It fails to build. What???

This is running BCB4.00 EE Trial version OR BCB4 Pro release on two
different  NT Server machines, both of them with Delphi 4 installed.

Also a VCL control I've written will not port, it  keeps complaining about
the linker not finding wsprintfA, no matter whether I define UNICODE or not.
The Pascal code uses Strings, PChars, and calls wsprintf onto a PChar, and
compiles fine under D4. I wonder if this is related.

Can someone try the above trivial automation server test and tell me what
they see? Am I overlooking something obvious in how to set up BCB for COM?

Thanks,
Fernand

 

Re:WideStrings and BSTR broken in BCB4 COM? Help?


Quote
Fernand Raynaud wrote:

> I am having some trouble with BCB4 COM work, coming from Delphi4 and VC++6.
> There seems to be something wong with the handling of widestrings in UNICODE
> mode.

> If I wizard-build a trivial Automation server, with a simple method or
> (even) no methods, and I try to compile it, it starts throwing const char*
> to const wchar_t* conversion errors in utilcls.h, atlvcl.h and other core
> includes. If I remove the UNICODE definition in the project conditionals, it
> compiles OK. This is with NO manually generated code in the project.

> Test case: Just start a new app, add an ActiveX automation object, make sure
> the project defines UNICODE, save it, compile it. It fails to build. What???

Whoops. Looks like we didn't test for that.
I've entered this as a bug, and we'll try to get it fixed ASAP.

Quote
> This is running BCB4.00 EE Trial version OR BCB4 Pro release on two
> different  NT Server machines, both of them with Delphi 4 installed.

> Also a VCL control I've written will not port, it  keeps complaining about
> the linker not finding wsprintfA, no matter whether I define UNICODE or not.
> The Pascal code uses Strings, PChars, and calls wsprintf onto a PChar, and
> compiles fine under D4. I wonder if this is related.

A VCL ActiveX control, or a regular control?
Seems like an entirely different issue to me.

Robert West
borland.com QA.

Re:WideStrings and BSTR broken in BCB4 COM? Help?


Quote
aphrael wrote in message <36FA6B2E.27E9D...@burble.org>...
>> Test case: Just start a new app, add an ActiveX automation object, make
sure
>> the project defines UNICODE, save it, compile it. It fails to build.
What???

>Whoops. Looks like we didn't test for that.
>I've entered this as a bug, and we'll try to get it fixed ASAP.

I'm very glad you entered it as a bug, but I can't help but wonder how you
*did* test if the most basic COM objects cannot be built.

This is getting me worried. I have had to manually revert to an older
4.0.5.106 VCL40.BPL since the latest 4.0.5.108 crashes my BCB4 Pro, and now
I'm wondering if any of the COM stuff works.

What do you recommend on this COM object stuff, I've got work to get done.
Not use UNICODE??? How can I get a fix ASAP, as troubleshooting the BCB4 ATL
source stuff is a little beyond me at the moment?

BTW, can you tell me how, in BCB4, one connects to a server's COM events
from the client side? Is there any documentation on that?

Quote
>> Also a VCL control I've written will not port, it  keeps complaining
about
>> the linker not finding wsprintfA, no matter whether I define UNICODE or
not.
>> The Pascal code uses Strings, PChars, and calls wsprintf onto a PChar,
and
>> compiles fine under D4. I wonder if this is related.

>A VCL ActiveX control, or a regular control?
>Seems like an entirely different issue to me.

This is a non-ActiveX control, just a standard VCL control that handles
serial ports. The thing I don't understand is that wsprintfA (indeed the
right permutation of wsprintf for the ASCII case), is not found by the BCB4
linker, yet the reference is there OK in the .obj file. Is there some global
widestring setting or problem here?

Quote
>Robert West
>borland.com QA.

Thanks,
Fernand
fraynaudATzdnetmailDOTcom

Re:WideStrings and BSTR broken in BCB4 COM? Help?


Quote
Fernand Raynaud wrote:
> I'm very glad you entered it as a bug, but I can't help but wonder how you
> *did* test if the most basic COM objects cannot be built.

We never tested with UNICODE defined on a project-wide basis.

Quote
> What do you recommend on this COM object stuff, I've got work to get done.

For the moment, either don't define UNICODE, or define UNICODE only for source
files which depend on it being defined.

Note that all the utilcls-type functions call SysAllocString for string
allocation, so defining UNICODE should not be necessary.

Quote
> BTW, can you tell me how, in BCB4, one connects to a server's COM events
> from the client side? Is there any documentation on that?

There is no documentation on this, no.

Quote
> This is a non-ActiveX control, just a standard VCL control that handles
> serial ports. The thing I don't understand is that wsprintfA (indeed the
> right permutation of wsprintf for the ASCII case), is not found by the BCB4
> linker, yet the reference is there OK in the .obj file. Is there some global
> widestring setting or problem here?

The reference is there OK in _which_ .obj file?

Re:WideStrings and BSTR broken in BCB4 COM? Help?


: "Fernand Raynaud" <fern...@elysee.fr> wrote:

Quote
>This is a non-ActiveX control, just a standard VCL control that handles
>serial ports. The thing I don't understand is that wsprintfA (indeed the
>right permutation of wsprintf for the ASCII case), is not found by the BCB4
>linker, yet the reference is there OK in the .obj file. Is there some global
>widestring setting or problem here?

There is a similar problem for service applications currently (fix
already for the future, as it appears):

If you naively build a service application and then drop a client
socket on the service container AND if you use SetPort then you get
"interesting" linker errors "TCustom..::SetPortA" not found.

The reason? Microsoft grab "SetPort" and #define it to "SetPortA".
Very kind. I have no idea whether these are related, but that may
perhaps give a clue where to look? OTOH, if it is OK in the OBJ (how
did you check? TDUMP?), then I am clueless.

Sorry, my knowledge about ATL-based COM is next to zero, so I am of
absolutely no help in that area.

--
Stefan Hoffmeister      http://www.econos.de/
Due to time constraints I cannot give free face-to-face advice.
Please do apply judgement when sending email.

Re:WideStrings and BSTR broken in BCB4 COM? Help?


Hi, Stefan,

Many of the Win32 calls obviously come in two flavors: A and W, ASCII and
WideString, not as a Microsoft "unkindness", but to let you either use
UNICODE or not. If I use wsprint in an ASCII build, not UNICODE, the call
should map to wsprintfA. You can see this in Borland's Windows.pas file.
Borland does this mapping, not Microsoft. That wsprintfA in turn should link
as an extern and resolve at runtime to an API call in User32. Right?

In BCB4 I see that my wsprintf has been mapped correctly to wsprintfA, in
myVCLsource.obj, if I use TDUMP. But it can't link. It's as if the wsprintfA
extern were not available to the linker, but I CAN use wsprintf (and
wsprintfA) allright in non-component code.

Something seems different in how a component (vs. an app) is linked. If I
replace wsprintf explicitly with wsprintfA in my source, or if I
undefine/undefine UNICODE, nothing changes.

Fernand

BTW, the same A vs. W split is true of SetPort, take a look, it's in the
WinSpool.pas file. It's a Win32 call in the default namespace, and maybe
that's the source of your service problem.

Quote
Stefan Hoffmeister wrote in message

<374fc2ac.37849...@forums.inprise.com>...
Quote
>: "Fernand Raynaud" <fern...@elysee.fr> wrote:

>There is a similar problem for service applications currently (fix
>already for the future, as it appears):

>If you naively build a service application and then drop a client
>socket on the service container AND if you use SetPort then you get
>"interesting" linker errors "TCustom..::SetPortA" not found.

>The reason? Microsoft grab "SetPort" and #define it to "SetPortA".
>Very kind. I have no idea whether these are related, but that may
>perhaps give a clue where to look? OTOH, if it is OK in the OBJ (how
>did you check? TDUMP?), then I am clueless.

>Sorry, my knowledge about ATL-based COM is next to zero, so I am of
>absolutely no help in that area.

Re:WideStrings and BSTR broken in BCB4 COM? Help?


: "Fernand Raynaud" <fern...@elysee.fr> wrote:

Quote
>In BCB4 I see that my wsprintf has been mapped correctly to wsprintfA, in
>myVCLsource.obj, if I use TDUMP.

OK. Point taken.

Quote
>But it can't link. It's as if the wsprintfA
>extern were not available to the linker, but I CAN use wsprintf (and
>wsprintfA) allright in non-component code.

Interesting - and no clue. You may want to repost this with all the
details in .commandlinetools or .ide, or possibly .language (please
only one group <g>)

Quote

>BTW, the same A vs. W split is true of SetPort, take a look, it's in the
>WinSpool.pas file. It's a Win32 call in the default namespace, and maybe
>that's the source of your service problem.

It was <g>. And yes, that's the problem - MS redefining SetPort with
the side-effect on the HPP from the Pascal source code. Very nice,
indeed.

, please do not cross- or multi-post, as this is against the guidelines for these newsgroups (see http://www.borland.com/newsgroups/). Please choose the *single* most appropriate newsgroup for your message and post it there. Thank you.

Re:WideStrings and BSTR broken in BCB4 COM? Help?


Quote
Stefan Hoffmeister wrote in message

<36fb853a.16394...@forums.inprise.com>...

Quote
>>But it can't link. It's as if the wsprintfA
>>extern were not available to the linker, but I CAN use wsprintf (and
>>wsprintfA) allright in non-component code.

>Interesting - and no clue. You may want to repost this with all the
>details in .commandlinetools or .ide, or possibly .language (please
>only one group <g>)

Thanks, I will try that.

Quote

>>BTW, the same A vs. W split is true of SetPort, take a look, it's in the
>>WinSpool.pas file. It's a Win32 call in the default namespace, and maybe
>>that's the source of your service problem.

>It was <g>. And yes, that's the problem - MS redefining SetPort with
>the side-effect on the HPP from the Pascal source code. Very nice,
>indeed.

Stefan, Liebschen,

That's just not right. It is BORLAND and not Microsoft that is "redefining"
here. SetPort had been a spooler Win32 API call since 1996, a pretty dumb
name, but it's been that way for about 3 years. In fact it was BORLAND that
both introduced the conflicting socket SetPort *and* imported the Win32
SetPort in Delphi 3, at least a year later.

That's why I think you're being a bit TApologist here, some people would
rather always see it the other way around, and this is how these anti-MS
rumors start. Please be fair.

As to why it only broke code in BCB4, I don't know.

Fernand

p.s. There is also a SetPort in java.net.

Re:WideStrings and BSTR broken in BCB4 COM? Help?


In article <370BEE8B.9DF82...@bogor.wasantara.net.id>,

Quote
yuli  <y...@bogor.wasantara.net.id> wrote:
>I am also having a problem with BSTR and WideString in BCB4.
>Using MapObjects ActiveX ver 1.2 from ESRI,  the code below is OK in compiling,
>but error during linking:

>      _DataConnectionDisp *dc;
>      dc = new _DataConnectionDisp;
>      dc->Database = (WideString("[arc]c:\\GisPangan\\Data").Detach());

>Database is a field in _DataConnectionDisp object with "type" = BSTR and
>"visibility" = public.

>Thanks for the attention,

Yuli,

what is the linker error in question?

Re:WideStrings and BSTR broken in BCB4 COM? Help?


Hello...

I am also having a problem with BSTR and WideString in BCB4.
Using MapObjects ActiveX ver 1.2 from ESRI,  the code below is OK in compiling,
but error during linking:

      _DataConnectionDisp *dc;
      dc = new _DataConnectionDisp;
      dc->Database = (WideString("[arc]c:\\GisPangan\\Data").Detach());

Database is a field in _DataConnectionDisp object with "type" = BSTR and
"visibility" = public.

Thanks for the attention,

best regards,

Yuli S.

Quote
aphrael wrote:
> Fernand Raynaud wrote:

> > I am having some trouble with BCB4 COM work, coming from Delphi4 and VC++6.
> > There seems to be something wong with the handling of widestrings in UNICODE
> > mode.

> > If I wizard-build a trivial Automation server, with a simple method or
> > (even) no methods, and I try to compile it, it starts throwing const char*
> > to const wchar_t* conversion errors in utilcls.h, atlvcl.h and other core
> > includes. If I remove the UNICODE definition in the project conditionals, it
> > compiles OK. This is with NO manually generated code in the project.

> > Test case: Just start a new app, add an ActiveX automation object, make sure
> > the project defines UNICODE, save it, compile it. It fails to build. What???

> Whoops. Looks like we didn't test for that.
> I've entered this as a bug, and we'll try to get it fixed ASAP.

> > This is running BCB4.00 EE Trial version OR BCB4 Pro release on two
> > different  NT Server machines, both of them with Delphi 4 installed.

> > Also a VCL control I've written will not port, it  keeps complaining about
> > the linker not finding wsprintfA, no matter whether I define UNICODE or not.
> > The Pascal code uses Strings, PChars, and calls wsprintf onto a PChar, and
> > compiles fine under D4. I wonder if this is related.

> A VCL ActiveX control, or a regular control?
> Seems like an entirely different issue to me.

> Robert West
> borland.com QA.

Re:WideStrings and BSTR broken in BCB4 COM? Help?


Quote
: yuli <y...@bogor.wasantara.net.id> wrote:
>but error during linking:

Which error during linking on which line in your source code (and
please show us that section of the source code)

--
Stefan Hoffmeister (TeamB)     http://www.econos.de/
Please do apply judgement when sending email.

Re:WideStrings and BSTR broken in BCB4 COM? Help?


Thank you for the responds. I am sorry for not being clear enough.

I put the code in :
    void __fastcall TForm1::FormCreate(TObject *Sender)
    {
      _DataConnectionDisp *dc;
      dc = new _DataConnectionDisp;
      dc->Database = (WideString("[arc]c:\\GisPangan\\Data").Detach());  // problem!

     }

if I compile the unit, it is OK. But when I try to run there is a dialog message
with the title:
            _ASSERTE,
and the question mark with message:
            IsBound()@
            PROGRA~1\BORLAND\CBUILD~1\INCLUDE\vcl/utilcls.h/2431
            Press [Y]es to terminate, [N]o to continue and [C]ancel to debug

Thanks again for the respond.

best regards,

Yuli S.

Quote
aphr...@shausle3.inprise.com wrote:
> In article <370BEE8B.9DF82...@bogor.wasantara.net.id>,
> yuli  <y...@bogor.wasantara.net.id> wrote:

> >I am also having a problem with BSTR and WideString in BCB4.
> >Using MapObjects ActiveX ver 1.2 from ESRI,  the code below is OK in compiling,
> >but error during linking:

> >      _DataConnectionDisp *dc;
> >      dc = new _DataConnectionDisp;
> >      dc->Database = (WideString("[arc]c:\\GisPangan\\Data").Detach());

> >Database is a field in _DataConnectionDisp object with "type" = BSTR and
> >"visibility" = public.

> >Thanks for the attention,

> Yuli,

> what is the linker error in question?

Re:WideStrings and BSTR broken in BCB4 COM? Help?


Thank you for the responds. I am sorry for not being clear enough.

I put the code in :
    void __fastcall TForm1::FormCreate(TObject *Sender)
    {
      _DataConnectionDisp *dc;
      dc = new _DataConnectionDisp;
      dc->Database = (WideString("[arc]c:\\GisPangan\\Data").Detach());  // problem!

     }

if I compile the unit, it is OK. But when I try to run there is a dialog message
with the title:
            _ASSERTE,
and the question mark with message:
            IsBound()@
            PROGRA~1\BORLAND\CBUILD~1\INCLUDE\vcl/utilcls.h/2431
            Press [Y]es to terminate, [N]o to continue and [C]ancel to debug

Thanks again for the respond.

best regards,

Yuli S.

Quote
aphr...@shausle3.inprise.com wrote:
> In article <370BEE8B.9DF82...@bogor.wasantara.net.id>,
> yuli  <y...@bogor.wasantara.net.id> wrote:

> >I am also having a problem with BSTR and WideString in BCB4.
> >Using MapObjects ActiveX ver 1.2 from ESRI,  the code below is OK in compiling,
> >but error during linking:

> >      _DataConnectionDisp *dc;
> >      dc = new _DataConnectionDisp;
> >      dc->Database = (WideString("[arc]c:\\GisPangan\\Data").Detach());

> >Database is a field in _DataConnectionDisp object with "type" = BSTR and
> >"visibility" = public.

> >Thanks for the attention,

> Yuli,

> what is the linker error in question?

Other Threads