Announcement

Collapse
No announcement yet.

Resizing VB6 string

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Resizing VB6 string

    Hello,

    I know VB and PB strings are interchangable.
    I just wrote a VB6 and PB6 app and DLL to fill a VB's string from within the DLL.
    It seems to work fine.

    Are there any problems i might encounter?

    Both procedures uses the string byref

    Like;
    Declare Function MyDLLFunc Lib"MYDLL.DLL"( sdata As String ) As Long

    ??


    ------------------
    hellobasic

  • #2
    I would be careful. VB Strings are OLE compliant and
    you should use the "SysString" family of functions to
    create and return strings to VB. There is also a document
    that describes the proper conventions of usage.

    VB uses the Unicode (double byte) versions of strings
    internally and then copies and creates the single byte
    versions when they are passed to DLL's. This is also
    true if the strings are contained in UDT's. When the
    DLL returns, VB reconstructs the Unicode versions.

    It is possible that if you are writing into the memory
    pointed to by a string, that it might move during garbage
    collection, thus causing a GPF.

    I hope that all of this doesn't discourage you because it
    is valuable to be able to use variable length strings as
    arguments to DLL's - Just follow the rules!

    Regards,

    Tony



    ------------------

    Comment


    • #3
      Be sure to review the FAQ on VB strings in the FAQ forum, and in the "Working with Visual Basic" section of the PB help file.


      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment

      Working...
      X