Wininet problems 
Author Message
 Wininet problems

Hi All,

I want to use the wininet.dll functions to add ftp capability to an
application.  I'm using PBDll 6.0.  As I understand it, the idea is to
use internetopen() to obtain a net handle, then use internetconnect() to
obtain a session handle for the ftp site, perform desired ftp operations
and then use internetclosehandle to end the ftp session.

Below is a code fragment that ought to obtain these handles and display
them in message boxes.  When I try to compile it, I get an error 266
duplicate name definition error pointing to the line envoking the
internetconnect() function.

Can anyone spot my mistake?  Has anyone used these functions
successfully and could point me to some sample code or documentation?

Thanks in advance,
George

' open an ftp connection, display connection handle and close connection

#dim all
#compile exe

DECLARE FUNCTION InternetOpen LIB "WININET.DLL" ALIAS "InternetOpenA" (lpszAgent AS ASCIIZ, BYVAL dwAccessType AS DWORD, lpszProxy AS ASCIIZ, lpszProxyBypass AS ASCIIZ, BYVAL dwFlags As DWORD) AS LONG
DECLARE SUB InternetConnect LIB "WININET.DLL" ALIAS "InternetConnectA" (BYVAL hInternet AS LONG, lpszServerName AS ASCIIZ, BYVAL nServerPort AS WORD, lpszUserName AS ASCIIZ, lpszPassword AS ASCIIZ, BYVAL dwService AS DWORD, BYVAL dwFlags AS DWORD, BYVAL dwContext AS DWORD)
DECLARE FUNCTION InternetCloseHandle LIB "WININET.DLL" ALIAS "InternetCloseHandle" (BYVAL hInternet AS LONG) AS LONG

%INTERNET_OPEN_TYPE_PRECONFIG   = 0   ' use registry configuration
%INTERNET_SERVICE_FTP    = 1
%INTERNET_INVALID_PORT_NUMBER   = 0           ' use the protocol-specific default

function pbmain() as long

dim hSession as long
dim hInternet as long

hInternet = InternetOpen("TN 2.0", byval %internet_open_type_preconfig, _
"", "", 0)
msgbox str$(hInternet), , " "
hSession = internetConnect hInternet, "ftp.xmission.com", _

%Internet_Service_ftp, 0, 0
msgbox str$(hSession), , " "
InternetCloseHandle hSession
end function



Sun, 25 Jan 2004 01:03:04 GMT  
 Wininet problems

Quote:

> Hi All,

> I want to use the wininet.dll functions to add ftp capability to an
> application.  I'm using PBDll 6.0.  As I understand it, the idea is to
> use internetopen() to obtain a net handle, then use internetconnect() to
> obtain a session handle for the ftp site, perform desired ftp operations
> and then use internetclosehandle to end the ftp session.

> Below is a code fragment that ought to obtain these handles and display
> them in message boxes.  When I try to compile it, I get an error 266
> duplicate name definition error pointing to the line envoking the
> internetconnect() function.

> Can anyone spot my mistake?  Has anyone used these functions
> successfully and could point me to some sample code or documentation?

> Thanks in advance,
> George

> ' open an ftp connection, display connection handle and close connection

> #dim all
> #compile exe

> DECLARE FUNCTION InternetOpen LIB "WININET.DLL" ALIAS "InternetOpenA" (lpszAgent AS ASCIIZ, BYVAL dwAccessType AS DWORD, lpszProxy AS ASCIIZ, lpszProxyBypass AS ASCIIZ, BYVAL dwFlags As DWORD) AS LONG
> DECLARE SUB InternetConnect LIB "WININET.DLL" ALIAS "InternetConnectA" (BYVAL hInternet AS LONG, lpszServerName AS ASCIIZ, BYVAL nServerPort AS WORD, lpszUserName AS ASCIIZ, lpszPassword AS ASCIIZ, BYVAL dwService AS DWORD, BYVAL dwFlags AS DWORD, BYVAL dwContext AS DWORD)
> DECLARE FUNCTION InternetCloseHandle LIB "WININET.DLL" ALIAS "InternetCloseHandle" (BYVAL hInternet AS LONG) AS LONG

> %INTERNET_OPEN_TYPE_PRECONFIG   = 0   ' use registry configuration
> %INTERNET_SERVICE_FTP    = 1
> %INTERNET_INVALID_PORT_NUMBER   = 0           ' use the protocol-specific default

> function pbmain() as long

> dim hSession as long
> dim hInternet as long

> hInternet = InternetOpen("TN 2.0", byval %internet_open_type_preconfig, _
> "", "", 0)
> msgbox str$(hInternet), , " "
> hSession = internetConnect hInternet, "ftp.xmission.com", _

> %Internet_Service_ftp, 0, 0
> msgbox str$(hSession), , " "
> InternetCloseHandle hSession
> end function

You declared a sub, but are using it as a function.

--
Peter Manders.
"Special today -- no ice cream."

Please remove the 'u' to reply.



Sun, 25 Jan 2004 15:38:15 GMT  
 Wininet problems
Thanks, Peter.  That's exactly what I did.  Gotta watch these late-night
programming sessions. <g>

Thanks again,
George



Mon, 26 Jan 2004 08:58:49 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. WININET.ASM/WIN-ME - To learn assembler I dis-ass'd WININET.DLL.

2. WININET doesn't always work

3. Accessing HTTP servers, wininet.dll

4. wsock.dll, wininet wrapper in STX

5. Wininet API Declarations for PB/DLL

6. WININET.DLL - pse HELP

7. declaring DLL variables WININET.DLL

8. Wininet guide

9. WININET.DLL - pointer parameter woes

10. Wininet and InternetSetStatus Function

11. What's wrong with this WININET prototype...

12. Using Wininet.dll

 

 
Powered by phpBB® Forum Software