Wininet Api

A

Altan Tunaboylu

Hello.i'm using these APIs.they are OK.

Public Declare Function InternetOpenW Lib "wininet.dll" Alias
"InternetOpenW" (ByVal sAgent As String, ByVal nAccessType As Int32, ByVal
sProxy As String, ByVal sProxyBypass As String, ByVal nFlags As Int32) As
Int32

Public Declare Function InternetConnectW Lib "wininet.dll" Alias
"InternetConnectW" (ByVal hInternet As Int32, ByVal ServerName As String,
ByVal ServerPort As Int16, ByVal sUserName As String, ByVal sPassword As
String, ByVal nService As Int32, ByVal nFlags As Int32, ByVal nContext As
Int32) As Int32

But ,when i wanna use these,i've got "SystemNotSupportedExecption".what is
wrong?

Public Declare Function FtpDeleteFileW Lib "wininet.dll" Alias
"FtpDeleteFileW" (ByVal hFtpSession As Long, ByVal lpszFileName As String)
As Boolean

Public Declare Function FtpRenameFile Lib "wininet.dll" Alias
"FtpRenameFileA" (ByVal hFtpSession As Long, ByVal lpszExisting As String,
ByVal lpszNew As String) As Boolean

Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA"
(ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile
As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long,
ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean

Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA"
(ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal
lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long)
As Boolean



Altan
 
P

Paolo Gazzei

Assuming you're working in pocketpc... (i don't know other platforms...)
it's a problem with unicode strings.
I think this is a bug in wininet.dll...
In fact if you passa a "string" parameter those functions actually send to
the server the unicode string 2 bytes per char), so that the server is non
able to work with it. You should see this in the ftp server log, requests
with only the first char of the filename.
So you shuold declare a byte array, putting in it something like this:

dim sFilename as String="myfile.txt"
dim szFilename(sFilename.Length) as Byte

For i = 0 To sFileName.Length - 1
szFileName(i) = Asc(Mid(sFileName, i + 1, 1))
Next
szFileName(sFileName.Length) = vbNullString

changing the declaration of the external functions

however i had problems with FtpGet/PutFile functions, and i didn't solve it.
I am using other functions: FtpOpenFile, InternetReadFile,InternetWriteFile.
They work fine even if some extra coding is needed.

Hope this helps!
 
A

Alex Feinman [MVP]

PInvoked functions cannot have Long parameters. Long that you have used in
eVB or VB6 is now Int32. Replace all occurences of Long with Int32
Also in
Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA"
(ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal
lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long)
As Boolean

FtpPutFileA shouls be FtpPutFileW, as there are no xxxxA function in Windows
CE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top