Results 1 to 13 of 13
Thread: UNICODE FILE PATH
Hybrid View
-
16th May 2011 14:32 #1Registered User
Join Date: Nov:2006
Location: varna
Posts: 10
UNICODE FILE PATH
!!!
:
(.exe, .jpg .gif) Web site .
FILE PATH, .
:
"Run-time error '52': Bad file name or number" : "Open DestFile For Binary Access Write As #1"
, VB FILE PATH ANSI.
:
?Code:Case icResponseCompleted ' 12 Dim bDone As Boolean: bDone = False Dim tempArray() As Byte Open DestFile For Binary Access Write As #1 vtData = Inet1.GetChunk(1024, icByteArray) DoEvents If Len(vtData) = 0 Then bDone = True End If Do While Not bDone tempArray = vtData Put #1, , tempArray ' Get next chunk. vtData = Inet1.GetChunk(1024, icByteArray) DoEvents If Len(vtData) = 0 Then bDone = True End If Loop Close #1
-
16th May 2011 14:53 #2
DestFile . .
, Win32 API .Last edited by Bombera; 16th May 2011 at 15:10.
EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|
-
16th May 2011 15:54 #3Registered User
Join Date: Nov:2006
Location: varna
Posts: 10

, DestFile Open Put, . .
DestFile, "c:\test\\.jpg" unicode . (Unicode) MsgBox, DestFile :
Code:Msgbox DestFile
Last edited by vlado_sfi; 20th May 2011 at 15:50.
-
16th May 2011 16:14 #4
Open Unicode , , DestFile. ANSI DestFile, ?
, , , 95 98? ?EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|
-
16th May 2011 16:44 #5Registered User
Join Date: Nov:2006
Location: varna
Posts: 10
ANSI n c , ( FILE PATH ). "Language for non-Unicode programs" Bulgarian, . Unicode API WriteFile CreateFile, .
:
Open DestFile For Binary Access Write As #1Last edited by vlado_sfi; 16th May 2011 at 17:16.
-
16th May 2011 20:50 #6
.
CreateFileW WriteFileW. DLL-a, Kernel32.dll, . W ANSI . , ANSI MutiByteToWideChar WideCharToMultiByte, - VB. , ANSI , . , , , , , . VB.EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|
-
18th May 2011 09:47 #7Registered User
Join Date: Nov:2006
Location: varna
Posts: 10
!
.
:
WriteBytesToFile :Code:Case icResponseCompleted ' 12 Dim tempArray() As Byte Dim vtData As Variant Dim bDone As Boolean: bDone = False ' Get first chunk. vtData = Inet1.GetChunk(1024, icByteArray) DoEvents If Len(vtData) = 0 Then bDone = True End If Do While Not bDone tempArray = vtData ' Get next chunk. vtData = Inet1.GetChunk(1024, icByteArray) DoEvents If Len(vtData) = 0 Then bDone = True End If Loop Call WriteBytesToFile(DestFile , tempArray)
, 768 bytes, 3992 Kbytes.Code:Public Function WriteBytesToFile(Filename As String, TheData() As Byte, _ Optional NoOverwrite As Boolean = False) As Boolean Dim lHandle As Long Dim lSuccess As Long Dim lBytesWritten As Long, lBytesToWrite As Long If NoOverwrite = True And Dir(Filename) <> "" Then Exit Function lBytesToWrite = UBound(TheData) - LBound(TheData) lHandle = CreateFile(StrPtr(Filename), GENERIC_WRITE Or GENERIC_READ, _ 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0) If lHandle <> INVALID_HANDLE_VALUE Then lSuccess = WriteFile(lHandle, TheData(0), _ lBytesToWrite, lBytesWritten, 0) <> 0 If lSuccess <> 0 Then lSuccess = FlushFileBuffers(lHandle) lSuccess = CloseHandle(lHandle) End If End If ErrorHandler: WriteBytesToFile = lSuccess <> 0 End Function
?
-
18th May 2011 12:21 #8
vtData tempArray, . 768 .
Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others
-
19th May 2011 14:16 #9Registered User
Join Date: Nov:2006
Location: varna
Posts: 10
"Run-time error '13': Type Mismatch".
:
Code:Case icResponseCompleted ' 12 Dim tempArray() As Byte Dim vtData As Variant Dim bDone As Boolean: bDone = False Dim i As Long ' Get first chunk. vtData = Inet1.GetChunk(1024, icByteArray) DoEvents If Len(vtData) = 0 Then bDone = True End If i = -1 Do While Not bDone i = i + 1 ReDim Preserve tempArray(i + 1) As Byte tempArray(i) = vtData ' Get next chunk. vtData = Inet1.GetChunk(1024, icByteArray) DoEvents If Len(vtData) = 0 Then bDone = True End If Loop Call WriteBytesToFile(DestFile , tempArray)
--------- 14:16 --------- : 15:09 ---------
?
-
19th May 2011 16:22 #10
:
:Code:Case icResponseCompleted ' 12 Dim tempArray() As Byte Dim vtData As Variant Dim bDone As Boolean: bDone = False Do While Not bDone vtData = Inet1.GetChunk(1024, icByteArray) if Len(vtData) = 0 then bDone = True else tempArray = vtData Call WriteBytesToFile(DestFile , tempArray) end if Loop
Code:Public Function WriteBytesToFile(Filename As String, TheData() As Byte, _ Optional NoOverwrite As Boolean = False) As Boolean Dim lHandle As Long Dim lSuccess As Long Dim lBytesWritten As Long, lBytesToWrite As Long If NoOverwrite = True And Dir(Filename) <> "" Then Exit Function lBytesToWrite = UBound(TheData) - LBound(TheData) lHandle = CreateFile(StrPtr(Filename), GENERIC_WRITE Or FILE_APPEND_DATA, _ 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0) If lHandle <> INVALID_HANDLE_VALUE Then lSuccess = WriteFile(lHandle, TheData(0), _ lBytesToWrite, lBytesWritten, 0) <> 0 If lSuccess <> 0 Then lSuccess = FlushFileBuffers(lHandle) lSuccess = CloseHandle(lHandle) End If End If ErrorHandler: WriteBytesToFile = lSuccess <> 0 End FunctionGigabyte X570 Aorus Elite, AMD Ryzen 7 5800X@PBO+200, Noctua NH-D15, 2x16GB G.Skill F4-3600C17D-32GTZR, Palit GeForce RTX 4070 Ti GameRock Classic, 2x Sandisk Extreme II 240GB (not in RAID)+WD 320GB AAKS + WD40EZRZ + Toshiba X300 6GB, Cooler Master HAF 922, CORSAIR 750W CX
-
20th May 2011 12:12 #11Registered User
Join Date: Nov:2006
Location: varna
Posts: 10

, "Run-time error '35758': Unable to retrieve data" vtData = Inet1.GetChunk(1024, icByteArray) .
, 1023 bytes.
:
Code:Private Const GENERIC_WRITE = &H40000000 Private Const GENERIC_READ = &H80000000 Private Const FILE_ATTRIBUTE_NORMAL = &H80 Private Const CREATE_ALWAYS = 2 Private Const OPEN_ALWAYS = 4 Private Const INVALID_HANDLE_VALUE = -1 Private Const FILE_APPEND_DATA = &H4 Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, _ lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, _ lpNumberOfBytesRead As Long, ByVal lpOverlapped As Long) As Long Private Declare Function CloseHandle Lib "kernel32" ( _ ByVal hObject As Long) As Long Private Declare Function WriteFile Lib "kernel32" ( _ ByVal hFile As Long, lpBuffer As Any, _ ByVal nNumberOfBytesToWrite As Long, _ lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Long) As Long Private Declare Function CreateFile Lib "kernel32" _ Alias "CreateFileW" (ByVal lpFileName As Long, _ ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, _ ByVal lpSecurityAttributes As Long, _ ByVal dwCreationDisposition As Long, _ ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) _ As Long
Last edited by vlado_sfi; 20th May 2011 at 14:25.
-
19th June 2011 13:47 #12Registered User
Join Date: Nov:2006
Location: varna
Posts: 10

, . .
:
Code:Private Sub dn_btn_Click() Inet1.Execute "http://leselevesfrancais.files.wordpress.com/2008/10/eiffel-tower-picture.jpg", "GET" End Sub Private Sub Inet1_StateChanged(ByVal State As Integer) Dim vtData As Variant Dim tempArray() As Byte Dim DestFile As String: DestFile = "C:\test.jpg" Dim bDone As Boolean: bDone = False Dim curByte As Long: curByte = 0 Select Case State Case icResponseCompleted ' 12 Call CreateFileApi(DestFile) Do While Not bDone vtData = Inet1.GetChunk(1024, icByteArray) If Len(vtData) = 0 Then bDone = True Call WriteBytesToFile(DestFile, tempArray, curByte, , True) Else tempArray = vtData Call WriteBytesToFile(DestFile, tempArray, curByte) curByte = curByte + ((UBound(tempArray) - LBound(tempArray) + 1)) End If Loop Case icError '11 MsgBox Inet1.ResponseInfo, vbCritical, "ERROR!" End Select End SubCode:Option Explicit Dim lHandle As Long Private Const GENERIC_WRITE = &H40000000 Private Const GENERIC_READ = &H80000000 Private Const FILE_ATTRIBUTE_NORMAL = &H80 Private Const CREATE_ALWAYS = 2 Private Const OPEN_ALWAYS = 4 Private Const INVALID_HANDLE_VALUE = -1 Private Const FILE_APPEND_DATA = &H4 Private Declare Function CloseHandle Lib "kernel32" ( _ ByVal hObject As Long) As Long Private Declare Function WriteFile Lib "kernel32" ( _ ByVal hFile As Long, lpBuffer As Any, _ ByVal nNumberOfBytesToWrite As Long, _ lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Long) As Long Private Declare Function CreateFile Lib "kernel32" _ Alias "CreateFileW" (ByVal lpFileName As Long, _ ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, _ ByVal lpSecurityAttributes As Long, _ ByVal dwCreationDisposition As Long, _ ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) _ As Long
Code:Public Function WriteStringToFile(Filename As String, ByVal TheData As String, _ Optional NoOverwrite As Boolean = False) As Boolean Dim lHandle As Long Dim lSuccess As Long Dim lBytesWritten As Long, lBytesToWrite As Long lBytesToWrite = Len(TheData) lHandle = CreateFile(Filename, GENERIC_WRITE Or GENERIC_READ, _ 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0) If lHandle <> INVALID_HANDLE_VALUE Then lSuccess = WriteFile(lHandle, ByVal TheData, _ lBytesToWrite, lBytesWritten, 0) <> 0 If lSuccess <> 0 Then lSuccess = FlushFileBuffers(lHandle) lSuccess = CloseHandle(lHandle) End If End If ErrorHandler: WriteStringToFile = lSuccess <> 0 End FunctionCode:Public Function CreateFileApi(Filename As String, _ Optional NoOverwrite As Boolean = False) As Boolean Dim lSuccess As Long If NoOverwrite = True And Dir(Filename) <> "" Then Exit Function lHandle = CreateFile(StrPtr(Filename), GENERIC_WRITE Or FILE_APPEND_DATA, _ 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0) End Function.Code:Public Function WriteBytesToFile(Filename As String, TheData() As Byte, _ lcurByte As Long, Optional NoOverwrite As Boolean = False, Optional lisFinish As Boolean = False) As Boolean Dim lSuccess As Long Dim lBytesWritten As Long, lBytesToWrite As Long If NoOverwrite = True And Dir(Filename) <> "" Then Exit Function lBytesToWrite = (UBound(TheData) - LBound(TheData) + 1) If lisFinish = True Then MsgBox "Finish" lSuccess = FlushFileBuffers(lHandle) lSuccess = CloseHandle(lHandle) Exit Function Else If lHandle <> INVALID_HANDLE_VALUE Then lSuccess = WriteFile(lHandle, lcurByte, _ lBytesToWrite, lBytesWritten, 0) <> 0 End If End If ErrorHandler: WriteBytesToFile = lSuccess <> 0 End Function
-
6th July 2011 17:07 #13Registered User
Join Date: Nov:2006
Location: varna
Posts: 10
, , .




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in