ListDirData event in C++ - WeOnlyDo Discussion board

ListDirData event in C++ (General questions)

by cedral, Thursday, January 21, 2010, 00:08 (5420 days ago)

I am working in C++ and I need to modify the listing. In the list dir event I tried to do what the help file said but the type for the SAFEARRAY* is coming back as VT_RECORD not BYTE (unsigned char). I have...

CComSafeArray<BYTE> arrayDirData;
arrayDirData.Attach(DirData);

the attach fails because the DirData is type VT_RECORD not VT_UI1 (unsigned char).

Please can someone provide an example of how to modify the DirData SAFEARRAY in C++?

Re: ListDirData event in C++

by cedral, Thursday, January 21, 2010, 01:51 (5419 days ago) @ cedral

The answer is to fix the broken prototype in the fast notification mfc example. it should have been SAFEARRAY **, not SAFEARRAY*.

the following example works.

STDMETHODIMP CwodFTPDNotify::XNotify::ListDirData(IwodFTPDCom* Owner, IFtpUser* User, SAFEARRAY ** DirData, VARIANT_BOOL NamesOnly)
{
METHOD_PROLOGUE(CwodFTPDNotify, Notify);
FILE *f = fopen(DIRLISTING, rb );
if(f)
{
BYTE arrayBytes[256];
CComSafeArray<BYTE> arrayDirData;
int i = 0;
while((i = fread(arrayBytes, sizeof(BYTE), 256, f)))
{
for(int j = 0; j < i; j++)
{
arrayDirData.Add(arrayBytes[j]);
}
}
fclose(f);
arrayDirData.CopyTo(DirData);
}
return S_OK;
}