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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's wrong with this code ?

Status
Not open for further replies.

vuhuumau

Programmer
Aug 19, 2005
3
VN
Can any one tell me whats wrong with my code:

void CTestFtpDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CInternetSession * pInet;
if(pInet!=NULL)
{
pInet->Close();
delete pInet;
}

}
I always receive error when press Button1.
Thanks.
 
Well first of all, you create a pointer pInet without initializing it to anything. then immediately check to see if its NULL. As it stands the pointer contains no data at all, so it should never enter that IF check.
What error are you getting?
 
Actually, the pointer probably contains whatever garbage is on the stack. You probably want to make pInet a member of your class which gets initialized when the window is created.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top