Results 1 to 8 of 8

Thread: Passing string to API question??

  1. #1

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Ok, I've got a question about the API. In a book that I am reading, it says that all strings that are passed to an API function need to have a null terminated character appened to the end of the string. Here's my dilemma, in all of his examples he does not do this? So when would I want to append the String with the null character? Just need some clarification

  2. #2
    Addicted Member
    Join Date
    Feb 2001
    Location
    Upstate NY
    Posts
    210
    in my experience, you can pass strings to the API without a trailing null string and it will work fine. What version of VB are you using? I use VB6 and i've never had to add null strings to make certain functions work.
    < o >

  3. #3

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    I'm using VB6 Enterprise.

  4. #4

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Anyone Else?

  5. #5
    Guest
    I've never had to do this in VB before. I usually pass it ByVal, and it works fine.
    Code:
    SendMessage hWnd, WM_MESSGAE, &H34, ByVal "MyString"
    Is this book for VB? Or C?

  6. #6

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    It's a VB book, it says that if you do not use a null-terminating character at the end of the string, the program will possibly crash cause' it doesn't no when to stop reading the string. As much as you use it Megatron, if you haven't had any problems, I wont bother worrying about it then

  7. #7
    Guest
    Even if you do run into problems (which you probably wont) you could always add the null character manually.
    Code:
    MyStr = MyStr & vbNullChar

  8. #8

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Thanks for clearing it up for me Megatron...

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