From: Peter on
Dear all
I have written a VB6 app that mainly copies or renames files of certain
folders and subfolders.
To rename the files I use
Name sFilename As sNewfilename
to copy the files I use the Win32API function

Public Declare Function CopyFileEx Lib "Kernel32.dll" Alias "CopyFileExA"
(ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal
lpProgressRoutine As Long, lpData As Any, ByRef pbCancel As Long, ByVal
dwCopyFlags As Long) As Long
and call it like:
ret = CopyFileEx(sFilenames, sNewfilename, AddressOf CopyProgressRoutine,
ByVal 0&, bCancel, ByVal 0&)

Now I heard from a customer from Israel that the app does not work if the
filename or the folder contains non-ascii characters like
�,�,�,�,�,o,�,�,u
Then I made some tests on my PC with files/folders containing these
characters but here it works without any problems.
I couldn't debug the problem in detail yet somewhere my app reports a Error
52: Bad file name or number
What can be the reason for this error, does it have something to do with
unicode support and VB6 strings?
How can I fix this?
Regards
Peter

From: Peter on
Forgot to mention: I am located in Europe/Austria

"Peter" <peter_l(a)myrealbox.com> schrieb im Newsbeitrag
news:hjuett$hp0$1(a)mail1.sbs.de...
> Dear all
> I have written a VB6 app that mainly copies or renames files of certain
> folders and subfolders.
> To rename the files I use
> Name sFilename As sNewfilename
> to copy the files I use the Win32API function
>
> Public Declare Function CopyFileEx Lib "Kernel32.dll" Alias "CopyFileExA"
> (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal
> lpProgressRoutine As Long, lpData As Any, ByRef pbCancel As Long, ByVal
> dwCopyFlags As Long) As Long
> and call it like:
> ret = CopyFileEx(sFilenames, sNewfilename, AddressOf CopyProgressRoutine,
> ByVal 0&, bCancel, ByVal 0&)
>
> Now I heard from a customer from Israel that the app does not work if the
> filename or the folder contains non-ascii characters like
> �,�,�,�,�,o,�,�,u
> Then I made some tests on my PC with files/folders containing these
> characters but here it works without any problems.
> I couldn't debug the problem in detail yet somewhere my app reports a
> Error 52: Bad file name or number
> What can be the reason for this error, does it have something to do with
> unicode support and VB6 strings?
> How can I fix this?
> Regards
> Peter
>

From: Dee Earley on
On 29/01/2010 10:57, Peter wrote:
> Dear all
> I have written a VB6 app that mainly copies or renames files of certain
> folders and subfolders.
> To rename the files I use
> Name sFilename As sNewfilename
> to copy the files I use the Win32API function
>
> Public Declare Function CopyFileEx Lib "Kernel32.dll" Alias
> "CopyFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName
> As String, ByVal lpProgressRoutine As Long, lpData As Any, ByRef
> pbCancel As Long, ByVal dwCopyFlags As Long) As Long
> and call it like:
> ret = CopyFileEx(sFilenames, sNewfilename, AddressOf
> CopyProgressRoutine, ByVal 0&, bCancel, ByVal 0&)
>
> Now I heard from a customer from Israel that the app does not work if
> the filename or the folder contains non-ascii characters like
> �,�,�,�,�,o,�,�,u
> Then I made some tests on my PC with files/folders containing these
> characters but here it works without any problems.
> I couldn't debug the problem in detail yet somewhere my app reports a
> Error 52: Bad file name or number
> What can be the reason for this error, does it have something to do with
> unicode support and VB6 strings?
> How can I fix this?

Change the "Language for non unicode apps" setting to match the charset
used to create the file.
Alternatively, use the W version of CopyFileEx and pass the strings as
pointers using strptr().

I Think:
Public Declare Function CopyFileEx Lib "Kernel32.dll" Alias
"CopyFileExW" (ByVal lpExistingFileName As long, ByVal lpNewFileName
As Long, ByVal lpProgressRoutine As Long, lpData As Any, ByRef
pbCancel As Long, ByVal dwCopyFlags As Long) As Long


--
Dee Earley (dee.earley(a)icode.co.uk)
i-Catcher Development Team

iCode Systems
From: Peter on
Thanks for your answer.
Inbetween I got the information from my customer that CopyFileExA seems to
work correct with non-ascii characters while the problem seems to come from
"Name As"
So as a next step I want to replace Name As with MoveFileExA
Regards
Peter

"Dee Earley" <dee.earley(a)icode.co.uk> schrieb im Newsbeitrag
news:uLyb3eNoKHA.4648(a)TK2MSFTNGP06.phx.gbl...
> On 29/01/2010 10:57, Peter wrote:
>> Dear all
>> I have written a VB6 app that mainly copies or renames files of certain
>> folders and subfolders.
>> To rename the files I use
>> Name sFilename As sNewfilename
>> to copy the files I use the Win32API function
>>
>> Public Declare Function CopyFileEx Lib "Kernel32.dll" Alias
>> "CopyFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName
>> As String, ByVal lpProgressRoutine As Long, lpData As Any, ByRef
>> pbCancel As Long, ByVal dwCopyFlags As Long) As Long
>> and call it like:
>> ret = CopyFileEx(sFilenames, sNewfilename, AddressOf
>> CopyProgressRoutine, ByVal 0&, bCancel, ByVal 0&)
>>
>> Now I heard from a customer from Israel that the app does not work if
>> the filename or the folder contains non-ascii characters like
>> �,�,�,�,�,o,�,�,u
>> Then I made some tests on my PC with files/folders containing these
>> characters but here it works without any problems.
>> I couldn't debug the problem in detail yet somewhere my app reports a
>> Error 52: Bad file name or number
>> What can be the reason for this error, does it have something to do with
>> unicode support and VB6 strings?
>> How can I fix this?
>
> Change the "Language for non unicode apps" setting to match the charset
> used to create the file.
> Alternatively, use the W version of CopyFileEx and pass the strings as
> pointers using strptr().
>
> I Think:
> Public Declare Function CopyFileEx Lib "Kernel32.dll" Alias
> "CopyFileExW" (ByVal lpExistingFileName As long, ByVal lpNewFileName
> As Long, ByVal lpProgressRoutine As Long, lpData As Any, ByRef
> pbCancel As Long, ByVal dwCopyFlags As Long) As Long
>
>
> --
> Dee Earley (dee.earley(a)icode.co.uk)
> i-Catcher Development Team
>
> iCode Systems