Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL

Tech-Archive recommends: Fix windows errors by optimizing your registry



>> When the above line of code is called on a pointer to memory without a
>> null terminator it will read past what you might consider to be the end
>> of
>> the string into random memory until it finds one.
>
> That is not happening in VB6. In Japanese VB6, the generated EXE always
> corrupts the ANSI string but still always appends a null char. In US VB6,
> in 25% of cases (depending on the string length but 100% reproducible in
> those cases) the generated EXE corrupts the ANSI string. But VB6 still
> always appends a null char, MSDN and several famous books describe that
> correctly.
>

Is there any way for you to provide a repro for the Japanese VB6 case? I
am not seeing any corruption on my part (I'm on US VB6) and so I don't think
I'm hitting the 25% case. If it is happening 100% of the time with Japanese
VB6 I wouldn't mind taking a look there instead.

> Aside: VB2003 sometimes screws it up in the way you say, not putting in a
> null char if the number of bytes in the ANSI version exactly holds the
> converted contents of the string.
>
>> It's possible that your customer's program might be making the same
>> assumption. This may result in crashes and other seemingly odd behavior.
>
> The customer's program doesn't do that. I wrote a few experiments in
> order
> to find out what was happening, and found corruption in the strings. As
> part of my experiments I found out where the null char is but the
> customer's
> program didn't depend on the null char that way.

Is the customers program using fixed-length strings or variable-length
strings? I am seeing differences between the two in terms of whether a null
character is put in at the end after going to the C dll. The fixed-length
string is not. The variable-length strings are. The fixed-length strings
are being filled up with space characters. Chr(0x20)

BTW, I saw on the the other thread on this topic that you may in fact
have found the problem and possibly the solution. I would recommend that
you upgrade to VB6 SP4 and see if that fixes the problem that you are
seeing. Have you been able to do that and how did that go? In addition,
the most recent version of VB6 is SP6 and I don't know if you would be
interested in upgrading to SP6 or not?

Trevor Short
Microsoft Visual Basic Development.


.



Relevant Pages

  • RE: Converting VB6 Fileopen/input/close to vb.net
    ... swallow and spit it out as a single string. ... stand alone components set for those VB6 file methods(such as FileOpen, ... Dim file_num As Integer = FreeFile ... For standard binary file read/write, in .NET, you can use BinaryReader ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Use of Mid Statement in VB.Net
    ... Dim buffer as New String(" "c, ... If you use VB6, then stick to your own group. ... Microsoft for the change in the language paradigm that VB.Net introduced. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Converting Quick Basic to Visual Basic
    ... "Bill McCarthy" wrote in message ... VB3 or earlier applications cannot be opened directly by VB6 IDE, and also require replacement of control libraries etc, etc. ... You still declare a String the same way and you assign and use strings the same way. ... could you imagine if every object had to have an ansi string property and a unicode string property for each property. ...
    (microsoft.public.vb.general.discussion)
  • Re: Using a dll vs. ocx
    ... The wrapper for VB6 appears to be a class. ... dll command in VFP. ... DECLARE integer AUDIOAnalyzeFile IN "AudioGenie2.dll" string ...
    (microsoft.public.fox.programmer.exchange)
  • Re: COM interop and Object Required
    ... string String ... int Long ... public class ComObject: IComInterface ... In VB6 I have added a reference to this class. ...
    (microsoft.public.dotnet.languages.csharp)