Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with LPSHELLFOLDER

Status
Not open for further replies.

dominochmiel

Programmer
Jan 28, 2003
40
PL
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!!!
 
I'm not sure what you are trying to do with
Code:
 String APath="C:\\asd.txt",path;
? It that even valid?

James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top