Click to See Complete Forum and Search --> : InternetOpen Issues


methsnax
March 24th, 2004, 12:47 PM
I am using InternetOpen in the following code and it continues to return a NULL handle. I have read over the API call on MSDN, looked at code here, and it seems perfectly fine. I even changed the access type.



HINTERNET hOpen;

//M$ function to get last error and report it
void error()
{
CHAR szBuf[80];
DWORD dw = GetLastError();

sprintf(szBuf, "%s failed: GetLastError returned ", dw);

MessageBox(NULL, szBuf, "Serials 2000 Auto-Updater", MB_OK);
ExitProcess(dw);
}

hOpen = InternetOpen(/*AfxGetAppName()*/"Updater",
INTERNET_OPEN_TYPE_PRECONFIG ,
NULL,
NULL,
INTERNET_FLAG_ASYNC);
error();



Thank you very much.

-Cheers-

NoHero
March 24th, 2004, 12:58 PM
I tested your stuff (I was connected (56k for 0wnage), the internet explorer was switched online)


hOpen = InternetOpen("Updater", INTERNET_OPEN_TYPE_PRECONFIG ,
NULL,
NULL,
INTERNET_FLAG_ASYNC);


and it worked :confused:

methsnax
March 24th, 2004, 03:05 PM
Maybe I'm hollucinating!!! Maybe its the following..
if(FtpGetFile(hFTP,
FindFileData.cFileName,
FindFileData.cFileName,
FALSE,
FILE_ATTRIBUTE_NORMAL,
FTP_TRANSFER_TYPE_BINARY,
dwContext) == FALSE)
{ //If the file can not be transfered lets do some error handling.
error();
} Although that does not look wrong either.. It's giving me an access violation.

-Cheers-

NoHero
March 24th, 2004, 03:38 PM
the last parameter is a pointer so write


if(FtpGetFile(hFTP,
FindFileData.cFileName,
FindFileData.cFileName,
FALSE,
FILE_ATTRIBUTE_NORMAL,
FTP_TRANSFER_TYPE_BINARY,
&dwContext) == FALSE)
{ //If the file can not be transfered lets do some error handling.
error();
}


instead of ... dwContext ...

if not the function represents the data in dwContext as a pointer and tries to access it --> error

methsnax
March 24th, 2004, 03:46 PM
FtpGetFileA' : cannot convert parameter 7 from 'unsigned long *' to 'unsigned long' dwContext is correct, it does not ask for a pointer...

-Cheers-

Andreas Masur
March 24th, 2004, 04:50 PM
Originally posted by methsnax
I am using InternetOpen in the following code and it continues to return a NULL handle.
Well...as usual...what does 'GetLastError()' return?

methsnax
March 24th, 2004, 10:02 PM
I figured the problem out, but it was a pain in the ***. Apparently the server wasn't up lol. Sorry to waste your time.

-Cheers-

NoHero
March 25th, 2004, 02:49 AM
you are welcome ;)

ng NoHero

Andreas Masur
March 25th, 2004, 05:37 AM
Originally posted by methsnax
I figured the problem out, but it was a pain in the ***. Apparently the server wasn't up lol. Sorry to waste your time.

Which should have been indicated by the error code... :cool:

methsnax
March 25th, 2004, 01:55 PM
It returned NULL..

-Cheers-

Andreas Masur
March 25th, 2004, 05:37 PM
Originally posted by methsnax
It returned NULL..

Yes...'InternetOpen()' returned a NULL handle, however, I rather meant, what 'GetLastError()' did return...

HINTERNET hOpen = InternetOpen("Updater",
INTERNET_OPEN_TYPE_PRECONFIG,
0,
0,
INTERNET_FLAG_ASYNC);
if(!hOpen)
// Error -> call 'GetLastError()