Results 1 to 6 of 6

Thread: Re: Copying content from a data structure into String field

  1. #1
    Guest

    Post

    Hi, all.

    I am trying to figure out the way to copy the content of a data structure
    into a string. The reason I would like to do this is because all I know
    about the structure is the pointer location. By copying the content of the
    structure, I should be able to get the information from the string located
    by the offset size of the item I am looking for.

    Currently, I am using CopyMemory function for this, but I haven't got any
    output yet. Here is my code.

    dim lineInfo as LINECALLINFO 'TAPI structure
    dim lineInfoStr as string

    CopyMemory byVal lineInfoStr, lineInfo, lineInfo.dwTotalSize

    After performing this, lineInfoStr var seems to be blank.

    Any suggestions?

    Thanx.

    Sean Kim


  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Because in your example you are trying to assign an Empty Structure to the String, plus then Number of Bytes to Copy would be Len(LINECALLINFO), but if you don't know the Structure, you can't know the Number of Bytes to pull back, so why do you dim a LINECALLINFO Struct and use it's dwTotalSize Property?

    The other thing is the String Buffer has to be Initialized to the Length of the Memory block to retrieve, eg.

    If you want the First 50 Bytes at the Specified Memory Location use LineInfo = Space(50) before calling the CopyMemory API.


    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

  3. #3
    Guest

    Post

    Oh....some confusion here I guess.

    That is just a part of the code. The structure, lineInfo, gets filled using the API function, lineGetCallInfo. And before calling the function, I specified the total size (dwTotalSize) of the structure.

    Before making the call, CopyMemory, lineInfo function is already filled with information.

    Hope this clarifieds...

    SK

  4. #4
    Guest

    Post

    The reason I would like to copy the data structure into a string is because the information I need is not accessed by any of its members. The structure itself is a variable sized structure. Only information I have from this data structure is the offset address and the size of the information I need. That's why I would like to copy the structure into a string from which I can get the part I need with the offset address and the size.

  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Well, initializing the String with Spaces should work, if not, post the Code here and I'll look at it.

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

  6. #6
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    ok, now I'm really confused.
    If you have the Data already in the Structure, whay are you then trying to copy it to a string, why not access the Value you want directly from the Structure?

    You Still need to Initilize the String Variable to the Length of the data to Retrieve, you can't just use an Empty String, unless it's fixed width.

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

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