Appending strings

Discussion in 'C Programming' started by sandeep, Jan 9, 2010.

  1. sandeep

    sandeep Guest

    Hello friends,

    I need to share a string between all instances of my dll. Also, I need
    to append to the string at each new instance of the dll.

    The string is declared:

    #pragma bss_seg("MYBSS")
    WCHAR* wFilenames;
    #pragma bss_seg()
    #pragma comment (linker,"/SECTION:MYBSS,rws")

    There's a routine that's called once per instance which recieves
    another string to append to wFilenames:

    QUICKEDITDLL bool STDCALL AddFilename(LPWSTR fn)
    {
    int s=(lstrlenW((LPCWSTR)wFilenames)+lstrlenW((LPCWSTR)fn)+2)*sizeof
    (WCHAR);
    // Plus 2 to accomedate a semicolon and a null char
    WCHAR* nS=(WCHAR*)malloc(s);
    ZeroMemory(nS,s);
    lstrcpyW(nS,wFilenames);
    //free(wFilenames);
    wFilenames=(WCHAR*)realloc(wFilenames,s);
    ZeroMemory(wFilenames,s);
    lstrcpyW(wFilenames,nS);
    lstrcatW(wFilenames,fn);
    lstrcatW(wFilenames,L";");
    MessageBoxW(NULL,wFilenames,NULL,MB_OK);
    free(nS);
    return true;
    }

    wFilenames only ever holds the last string ( fn ).

    I'm sure I've just missed something but I don't know what.

    Thanks,
    Sandeep
     
    sandeep, Jan 9, 2010
    #1
    1. Advertising

  2. sandeep

    Ian Collins Guest

    sandeep wrote:
    > Hello friends,
    >
    > I need to share a string between all instances of my dll. Also, I need
    > to append to the string at each new instance of the dll.


    <snip>

    > I'm sure I've just missed something but I don't know what.


    Probably the right group to post to! Try a windows specific group.

    --
    Ian Collins
     
    Ian Collins, Jan 9, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Cholakian

    Appending to XML

    Andrew Cholakian, Jul 17, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,064
    Andrew Cholakian
    Jul 17, 2003
  2. Jeff Cooper

    Netscape Appending .aspx to downloads

    Jeff Cooper, Oct 21, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    323
    Jeff Cooper
    Oct 21, 2003
  3. Steve E.
    Replies:
    0
    Views:
    330
    Steve E.
    Nov 11, 2003
  4. Philip Townsend

    Appending a DataSet

    Philip Townsend, Dec 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,526
  5. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    809
    Malcolm
    Jun 24, 2006
Loading...

Share This Page