S
sandeep
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
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