FreeRider Posted April 1, 2008 Posted April 1, 2008 (edited) *** PROBLEM FIXED *****I found a bypass to avoid the Error returned by the "FtpOpenFile" dll function when trying to open a file with the "$GENERIC_WRITE" parameterNow Both FtpFileRead and FtpFileWrite functions works and I will post a new version of the FTPV4.AU3 file which will include these functions.Postin Location will be : http://www.autoitscript.com/forum/index.ph...st&id=19302*** End of Block *********** Update Problem desc *****Problem comes from the FtpOpenFile function which does not work with the GENERIC_WRITE access parameterUsing GENERIC_READ do not produce any error... but do not allow to write into the fileIF SOMEONE COULD HELP... I WOULD APPRECIATE...Thks***************************Hi all,I'm looking for a function using the "InterNetWriteFile" function inlcuded in the Wininet.dll. i found one sample script in the forum but the autor says in the scriptthat the function do not work. I made a personal script but this does not work (Pointer problem I think).Here is the code of the function (base on the _FtpReadFile function which works fine)Thanks for your help...CODEFunc _FTPWriteFile($l_FTPSession,$SourceFile,$RemoteFile,$AccessType)Local $s_FileRead = "",$BytesWritten = 0,$dwNumberOfBytesToWrite,$lpdwNumberOfBytesWrittenLocal $dwNumberOfBytesToWrite = FileGetSize($SourceFile)Local $ai_FTPGetSizeHandle = DllCall('wininet.dll', 'int', 'FtpOpenFile', 'long', $l_FTPSession, 'str', $RemoteFile, 'long', $AccessType, 'long', 0x04000002, 'long', 0)Local $LocFileHndl=FileOpen($SourceFile,16)Local $DataToWrite=FileRead($LocFileHndl)MsgBox(0,"DATA TO WRITE",$DataToWrite)$lpBuffer = DllStructCreate("byte[" & StringTrimLeft($DataToWrite,2) & "]")$lpdwNumberOfBytesWritten = DllStructCreate("long") Local $ai_FTPReadFile = DllCall('wininet.dll', 'int', 'InternetWriteFile', _'hwnd', $ai_FTPGetSizeHandle[0], _ ; HINTERNET hFile'ptr', DllStructGetPtr($lpBuffer), _ ;LPVOID lpBuffer'dword', $dwNumberOfBytesToWrite, _ ;DWORD dwNumberOfBytesToWrite'ptr',DllStructGetPtr($lpdwNumberOfBytesWritten)) ;LPDWORD lpdwNumberOfBytesWritten$BytesWritten = DllStructGetData($lpdwNumberOfBytesWritten,1)If @error OR $ai_FTPReadFile[0] == 0 Then $lpBuffer = 0 $lpdwNumberOfBytesWritten = 0 If $BytesWritten == 0 Then SetError(-1) ;end-of-file error Else SetError(1) ;general error EndIf Return 0EndIf$s_FileRead = DllStructGetData($lpBuffer,1);index is omitted so the entire array is written into $s_FileRead as a BinaryString$lpBuffer = 0$lpdwNumberOfBytesWritten = 0If $BytesWritten = 1 Then Return _HexToString ( StringTrimLeft(Chr($s_FileRead),2)) ;without this a 1 byte read will return a decimal value of the 8 bits readElse Return _HexToString ( StringTrimLeft($s_FileRead,2)) ;return as binarystring (character string where all 0-255 ASCII values are allowed)EndIf EndFunc Edited April 3, 2008 by Christophe Savard FreeRiderHonour & Fidelity
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now