dominochmiel
Programmer
Can anybody tell me why this code after terminating app gives me an exception EAccessViolation.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
LPMALLOC as;
String APath="C:\\asd.txt";
LPSHELLFOLDER lpsf,lpssf;
LPENUMIDLIST lpenumidlist;
LPITEMIDLIST lpidl=NULL;
SHGetMalloc(&as);
if(SUCCEEDED(SHGetDesktopFolder(&lpsf)))
{
wchar_t WPath[MAX_PATH];
StringToWideChar(APath,WPath,MAX_PATH);
unsigned long eaten;
SHGetMalloc(&as);
lpsf->ParseDisplayName(NULL,NULL,WPath,&eaten,&lpidl,NULL);
SHGetMalloc(&as);
lpsf->BindToObject(lpidl,NULL,IID_IShellFolder,(LPVOID*)lpssf);
SHGetMalloc(&as);
lpsf->Release();
as->Release();
}
}
If I change String APath="C:\\asd.txt"; to String APath="C:\\asd.txt",path; it gives me an exception after button click. I know that it's stupid. But please help!!!
void __fastcall TForm1::Button1Click(TObject *Sender)
{
LPMALLOC as;
String APath="C:\\asd.txt";
LPSHELLFOLDER lpsf,lpssf;
LPENUMIDLIST lpenumidlist;
LPITEMIDLIST lpidl=NULL;
SHGetMalloc(&as);
if(SUCCEEDED(SHGetDesktopFolder(&lpsf)))
{
wchar_t WPath[MAX_PATH];
StringToWideChar(APath,WPath,MAX_PATH);
unsigned long eaten;
SHGetMalloc(&as);
lpsf->ParseDisplayName(NULL,NULL,WPath,&eaten,&lpidl,NULL);
SHGetMalloc(&as);
lpsf->BindToObject(lpidl,NULL,IID_IShellFolder,(LPVOID*)lpssf);
SHGetMalloc(&as);
lpsf->Release();
as->Release();
}
}
If I change String APath="C:\\asd.txt"; to String APath="C:\\asd.txt",path; it gives me an exception after button click. I know that it's stupid. But please help!!!