Problems using ReadDirectoryChanges in Rad Studio

40 Views Asked by At

I am trying to load a file into a stream in BASS via ReadDirectoryChanges. When I use a testfunction using FileOpenDialog I get a working result, but when I use RDC it craps out on me all the time. I must be doing something wrong, but for the life of me I can't figure it out. Maybe someone here can point me in the right direction. Below is a snippet of the code I use:

void __fastcall TForm9::ToWav(FILE_NOTIFY_INFORMATION* File)
{
    String FullFileName = OpokaClient.ImportLocation + copyfname(File);
    int BassResult = 0;


    LogLine("File added to: " + FullFileName, apSYSTEM);
    HSTREAM convert = NULL;

    convert = MyBASS_StreamCreateFile(false, FullFileName.c_str(), 0, 0, BASS_STREAM_DECODE | BASS_UNICODE);
    BassResult = MyBASS_ErrorGetCode();

    LogLine("Bass Result: " + IntToStr(BassResult), apSYSTEM);

}
//---------------------------------------------------------------------------

void __fastcall TForm9::Button2Click(TObject *Sender)
{
    String FileName;
    int BassResult = 0;

    if(FileOpenDialog1->Execute()) {
        FileName = FileOpenDialog1->FileName;
    } else {
        LogLine("No file selected. FileName empty", apWARNING);
        return;
    }

    HSTREAM convert = NULL;

    LogLine("ConverterMain: ToWav: FileName: " + FileName, apSYSTEM);

    convert = MyBASS_StreamCreateFile(false, FileName.c_str(), 0, 0, BASS_STREAM_DECODE | BASS_UNICODE);
    BassResult = MyBASS_ErrorGetCode();

    LogLine("chan ErrorCode: " + IntToStr(BassResult), apSYSTEM);

}
//---------------------------------------------------------------------------

copyfname is in a different unit..

wchar_t* copyfname(FILE_NOTIFY_INFORMATION* pfi)
{

    wchar_t* pfn;

    pfn = new wchar_t[pfi->FileNameLength+1];

    ZeroMemory(pfn, sizeof(wchar_t)*(pfi->FileNameLength+1));
    memcpy(pfn, pfi->FileName, pfi->FileNameLength);
    return pfn;
}
0

There are 0 best solutions below