CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 1999
    Location
    Austria
    Posts
    53

    pointer to a string

    A function needs a pointer to a buffer. I have a string and how can I make a pointer to this string


  2. #2
    Join Date
    Oct 1999
    Posts
    63

    Re: pointer to a string

    Strings in Visual Basic are stored as BSTR's. If you use the VarPtr on a variable of type String, you will get the address of the BSTR, which is a pointer to a pointer of the string. To get the address of the string buffer itself, you need to use the StrPtr function. This function returns the address of the first character of the string. Take into account that Strings are stored as UNICODE in Visual Basic.

    To get the address of the first character of a String, pass the String variable to the StrPtr function.

    Example:


    Dim lngCharAddress as Long
    Dim strMyVariable as String
    strMyVariable = "Some String"
    lngCharAddress = StrPtr(strMyVariable)


    You can use this function when you need to pass a pointer to a UNIOCODE string to an API call.


  3. #3
    Join Date
    Jul 1999
    Posts
    145

    Re: pointer to a string

    Can't you just create a buffer with the string function and then pass it ByVal?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured