PC Review


Reply
Thread Tools Rate Thread

CECreateFile invalide handle

 
 
Amirallia
Guest
Posts: n/a
 
      12th Feb 2009
HI,

I developped a VB 6.0 application to copy a files from PC to PocketPC.
I'm inspired by the source code on
http://www.devbuzz.com/Archived/zinc...ce_II_pg1.aspx

This application runs well on a lot of Mobile device from many years,
but on one device (PSION Workabout running under WM2003) I've got an
invalide handle when calling CECreateFile, and the CeGetLastError
returns 0.

I don't know where is the problem with this PSION

Any idea ???


 
Reply With Quote
 
 
 
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      12th Feb 2009
Show the code. We don't know what path you're trying to use to create the
file, for example...

Paul T.

"Amirallia" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HI,
>
> I developped a VB 6.0 application to copy a files from PC to PocketPC. I'm
> inspired by the source code on
> http://www.devbuzz.com/Archived/zinc...ce_II_pg1.aspx
>
> This application runs well on a lot of Mobile device from many years, but
> on one device (PSION Workabout running under WM2003) I've got an invalide
> handle when calling CECreateFile, and the CeGetLastError returns 0.
>
> I don't know where is the problem with this PSION
>
> Any idea ???
>
>



 
Reply With Quote
 
Amirallia
Guest
Posts: n/a
 
      12th Feb 2009
Paul G. Tobey [eMVP] avait soumis l'idée :
> Show the code. We don't know what path you're trying to use to create the
> file, for example...
>
> Paul T.
>
> "Amirallia" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> HI,
>>
>> I developped a VB 6.0 application to copy a files from PC to PocketPC. I'm
>> inspired by the source code on
>> http://www.devbuzz.com/Archived/zinc...ce_II_pg1.aspx
>>
>> This application runs well on a lot of Mobile device from many years, but
>> on one device (PSION Workabout running under WM2003) I've got an invalide
>> handle when calling CECreateFile, and the CeGetLastError returns 0.
>>
>> I don't know where is the problem with this PSION
>>
>> Any idea ???
>>
>>


Here is the code :

Public Function CopyFileToPocketPC(ptxtPPCFile As String,
ptxtDesktopFile As String) As Boolean

Dim bytBuffer(8388607) As Byte
Dim lngFileHandle As Long
Dim lngDestinationHandle As Long
Dim lngNumBytesWritten As Long
Dim filename As String
Dim typFindFileData As CE_FIND_DATA
Dim lngFileSize As Long

'On Error GoTo ErrHandler

'locate the file, and see if it already exists on the device
lngFileHandle = CeFindFirstFile(ptxtPPCFile, typFindFileData)

'if we get -1 then the file wasn't found so we can go ahead and create
it
'otherwise we dont want to overwrite in this demo, so we will cancel
the operation.

If lngFileHandle <> INVALID_HANDLE Then
'MsgBox txtPPCFile & " already exists. Operation Cancelled."
CeFindClose lngFileHandle
CopyFileToPocketPC = False
End If

'create the file on the device, and return the handle to the file
filename = ptxtPPCFile
lngDestinationHandle = CeCreateFile(filename, GENERIC_WRITE,
FILE_SHARE_READ, vbNullString, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)

'if something went wrong in CeCreateFile we will get -1, and therefore
need to abort
If lngDestinationHandle = INVALID_HANDLE Then
MsgBox "CeCreateFile Error " & CeGetLastError & " occurred.",
vbCritical & vbOKOnly
CopyFileToPocketPC = False
CeCloseHandle lngDestinationHandle
Exit Function
End If

'Call function to read file on the desktop into the byte buffer
If ReadFileAsBinary(ptxtDesktopFile, lngFileSize, bytBuffer()) = True
Then

'Write contents of Binary buffer to CE file.
'Return value of 0 = failure, non zero = success
intRetVal = CeWriteFile(lngDestinationHandle, bytBuffer(0),
lngFileSize, lngNumBytesWritten, 0)

If intRetVal = WRITE_ERROR Then
GoTo ErrHandler
End If

End If

CeCloseHandle lngDestinationHandle

CopyFileToPocketPC = True

Exit Function

ErrHandler:

MsgBox "Error " & CeGetLastError & " Occurred When Copying File " & _
ptxtDesktopFile & " To The Device as " & ptxtPPCFile, vbCritical &
vbOKOnly

If lngDestinationHandle Or lngDestinationHandle <> INVALID_HANDLE Then
CeCloseHandle lngDestinationHandle
End If
CopyFileToPocketPC = False

End Function


The function is called, for example,
CopyFileToPocketPC("\Temp\toto.txt","C:\Temp\toto.txt")


 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      12th Feb 2009
And is there a \temp folder on the device? Can you, using the user
interface on the device, create a file there? I don't think there's any
requirement that every device have such a folder.

Paul T.

"Amirallia" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Paul G. Tobey [eMVP] avait soumis l'idée :
>> Show the code. We don't know what path you're trying to use to create
>> the file, for example...
>>
>> Paul T.
>>
>> "Amirallia" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> HI,
>>>
>>> I developped a VB 6.0 application to copy a files from PC to PocketPC.
>>> I'm inspired by the source code on
>>> http://www.devbuzz.com/Archived/zinc...ce_II_pg1.aspx
>>>
>>> This application runs well on a lot of Mobile device from many years,
>>> but on one device (PSION Workabout running under WM2003) I've got an
>>> invalide handle when calling CECreateFile, and the CeGetLastError
>>> returns 0.
>>>
>>> I don't know where is the problem with this PSION
>>>
>>> Any idea ???
>>>
>>>

>
> Here is the code :
>
> Public Function CopyFileToPocketPC(ptxtPPCFile As String, ptxtDesktopFile
> As String) As Boolean
>
> Dim bytBuffer(8388607) As Byte
> Dim lngFileHandle As Long
> Dim lngDestinationHandle As Long
> Dim lngNumBytesWritten As Long
> Dim filename As String
> Dim typFindFileData As CE_FIND_DATA
> Dim lngFileSize As Long
>
> 'On Error GoTo ErrHandler
>
> 'locate the file, and see if it already exists on the device
> lngFileHandle = CeFindFirstFile(ptxtPPCFile, typFindFileData)
>
> 'if we get -1 then the file wasn't found so we can go ahead and create it
> 'otherwise we dont want to overwrite in this demo, so we will cancel the
> operation.
>
> If lngFileHandle <> INVALID_HANDLE Then
> 'MsgBox txtPPCFile & " already exists. Operation Cancelled."
> CeFindClose lngFileHandle
> CopyFileToPocketPC = False
> End If
>
> 'create the file on the device, and return the handle to the file
> filename = ptxtPPCFile
> lngDestinationHandle = CeCreateFile(filename, GENERIC_WRITE,
> FILE_SHARE_READ, vbNullString, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
>
> 'if something went wrong in CeCreateFile we will get -1, and therefore
> need to abort
> If lngDestinationHandle = INVALID_HANDLE Then
> MsgBox "CeCreateFile Error " & CeGetLastError & " occurred.",
> vbCritical & vbOKOnly
> CopyFileToPocketPC = False
> CeCloseHandle lngDestinationHandle
> Exit Function
> End If
>
> 'Call function to read file on the desktop into the byte buffer
> If ReadFileAsBinary(ptxtDesktopFile, lngFileSize, bytBuffer()) = True Then
>
> 'Write contents of Binary buffer to CE file.
> 'Return value of 0 = failure, non zero = success
> intRetVal = CeWriteFile(lngDestinationHandle, bytBuffer(0), lngFileSize,
> lngNumBytesWritten, 0)
>
> If intRetVal = WRITE_ERROR Then
> GoTo ErrHandler
> End If
>
> End If
>
> CeCloseHandle lngDestinationHandle
>
> CopyFileToPocketPC = True
>
> Exit Function
>
> ErrHandler:
>
> MsgBox "Error " & CeGetLastError & " Occurred When Copying File " & _
> ptxtDesktopFile & " To The Device as " & ptxtPPCFile, vbCritical &
> vbOKOnly
>
> If lngDestinationHandle Or lngDestinationHandle <> INVALID_HANDLE Then
> CeCloseHandle lngDestinationHandle
> End If
> CopyFileToPocketPC = False
>
> End Function
>
>
> The function is called, for example,
> CopyFileToPocketPC("\Temp\toto.txt","C:\Temp\toto.txt")
>
>



 
Reply With Quote
 
Amirallia
Guest
Posts: n/a
 
      16th Feb 2009
Paul G. Tobey [eMVP] a couché sur son écran :
> And is there a \temp folder on the device? Can you, using the user interface
> on the device, create a file there? I don't think there's any requirement
> that every device have such a folder.
>
> Paul T.
>
> "Amirallia" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Paul G. Tobey [eMVP] avait soumis l'idée :
>>> Show the code. We don't know what path you're trying to use to create the
>>> file, for example...
>>>
>>> Paul T.
>>>
>>> "Amirallia" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> HI,
>>>>
>>>> I developped a VB 6.0 application to copy a files from PC to PocketPC.
>>>> I'm inspired by the source code on
>>>> http://www.devbuzz.com/Archived/zinc...ce_II_pg1.aspx
>>>>
>>>> This application runs well on a lot of Mobile device from many years, but
>>>> on one device (PSION Workabout running under WM2003) I've got an invalide
>>>> handle when calling CECreateFile, and the CeGetLastError returns 0.
>>>>
>>>> I don't know where is the problem with this PSION
>>>>
>>>> Any idea ???
>>>>
>>>>

>>
>> Here is the code :
>>
>> Public Function CopyFileToPocketPC(ptxtPPCFile As String, ptxtDesktopFile
>> As String) As Boolean
>>
>> Dim bytBuffer(8388607) As Byte
>> Dim lngFileHandle As Long
>> Dim lngDestinationHandle As Long
>> Dim lngNumBytesWritten As Long
>> Dim filename As String
>> Dim typFindFileData As CE_FIND_DATA
>> Dim lngFileSize As Long
>>
>> 'On Error GoTo ErrHandler
>>
>> 'locate the file, and see if it already exists on the device
>> lngFileHandle = CeFindFirstFile(ptxtPPCFile, typFindFileData)
>>
>> 'if we get -1 then the file wasn't found so we can go ahead and create it
>> 'otherwise we dont want to overwrite in this demo, so we will cancel the
>> operation.
>>
>> If lngFileHandle <> INVALID_HANDLE Then
>> 'MsgBox txtPPCFile & " already exists. Operation Cancelled."
>> CeFindClose lngFileHandle
>> CopyFileToPocketPC = False
>> End If
>>
>> 'create the file on the device, and return the handle to the file
>> filename = ptxtPPCFile
>> lngDestinationHandle = CeCreateFile(filename, GENERIC_WRITE,
>> FILE_SHARE_READ, vbNullString, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
>>
>> 'if something went wrong in CeCreateFile we will get -1, and therefore need
>> to abort
>> If lngDestinationHandle = INVALID_HANDLE Then
>> MsgBox "CeCreateFile Error " & CeGetLastError & " occurred.", vbCritical
>> & vbOKOnly
>> CopyFileToPocketPC = False
>> CeCloseHandle lngDestinationHandle
>> Exit Function
>> End If
>>
>> 'Call function to read file on the desktop into the byte buffer
>> If ReadFileAsBinary(ptxtDesktopFile, lngFileSize, bytBuffer()) = True Then
>>
>> 'Write contents of Binary buffer to CE file.
>> 'Return value of 0 = failure, non zero = success
>> intRetVal = CeWriteFile(lngDestinationHandle, bytBuffer(0), lngFileSize,
>> lngNumBytesWritten, 0)
>>
>> If intRetVal = WRITE_ERROR Then
>> GoTo ErrHandler
>> End If
>>
>> End If
>>
>> CeCloseHandle lngDestinationHandle
>>
>> CopyFileToPocketPC = True
>>
>> Exit Function
>>
>> ErrHandler:
>>
>> MsgBox "Error " & CeGetLastError & " Occurred When Copying File " & _
>> ptxtDesktopFile & " To The Device as " & ptxtPPCFile, vbCritical & vbOKOnly
>>
>> If lngDestinationHandle Or lngDestinationHandle <> INVALID_HANDLE Then
>> CeCloseHandle lngDestinationHandle
>> End If
>> CopyFileToPocketPC = False
>>
>> End Function
>>
>>
>> The function is called, for example,
>> CopyFileToPocketPC("\Temp\toto.txt","C:\Temp\toto.txt")
>>
>>


Yes I can explorer my temp folder and copy files.

With an another mobile device(iPaq) it'ok but with an another(Psion
workabout), I 've got the error on CECreateFile

Where is the difference between this two devices?


 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      16th Feb 2009
You'd have to ask the device manufacturer to tell you, specifically, what's
different. In this case, if the Workabout *is* a Windows Mobile device, as
opposed to a Windows CE device, I can't explain the difference and you'll
*have* to talk to Psion about what's going on. My best guess would be a
problem with the path that you're specifying, whether that's a spelling
error in your code as compared with the device (maybe there's a space in the
name on one or the other, your filename matches a read-only file that
already exists in the folder, etc.), or some special functionality of the
folder on the Psion...

Paul T.

"Amirallia" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Paul G. Tobey [eMVP] a couché sur son écran :
>> And is there a \temp folder on the device? Can you, using the user
>> interface on the device, create a file there? I don't think there's any
>> requirement that every device have such a folder.
>>
>> Paul T.
>>
>> "Amirallia" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Paul G. Tobey [eMVP] avait soumis l'idée :
>>>> Show the code. We don't know what path you're trying to use to create
>>>> the file, for example...
>>>>
>>>> Paul T.
>>>>
>>>> "Amirallia" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> HI,
>>>>>
>>>>> I developped a VB 6.0 application to copy a files from PC to PocketPC.
>>>>> I'm inspired by the source code on
>>>>> http://www.devbuzz.com/Archived/zinc...ce_II_pg1.aspx
>>>>>
>>>>> This application runs well on a lot of Mobile device from many years,
>>>>> but on one device (PSION Workabout running under WM2003) I've got an
>>>>> invalide handle when calling CECreateFile, and the CeGetLastError
>>>>> returns 0.
>>>>>
>>>>> I don't know where is the problem with this PSION
>>>>>
>>>>> Any idea ???
>>>>>
>>>>>
>>>
>>> Here is the code :
>>>
>>> Public Function CopyFileToPocketPC(ptxtPPCFile As String,
>>> ptxtDesktopFile As String) As Boolean
>>>
>>> Dim bytBuffer(8388607) As Byte
>>> Dim lngFileHandle As Long
>>> Dim lngDestinationHandle As Long
>>> Dim lngNumBytesWritten As Long
>>> Dim filename As String
>>> Dim typFindFileData As CE_FIND_DATA
>>> Dim lngFileSize As Long
>>>
>>> 'On Error GoTo ErrHandler
>>>
>>> 'locate the file, and see if it already exists on the device
>>> lngFileHandle = CeFindFirstFile(ptxtPPCFile, typFindFileData)
>>>
>>> 'if we get -1 then the file wasn't found so we can go ahead and create
>>> it
>>> 'otherwise we dont want to overwrite in this demo, so we will cancel the
>>> operation.
>>>
>>> If lngFileHandle <> INVALID_HANDLE Then
>>> 'MsgBox txtPPCFile & " already exists. Operation Cancelled."
>>> CeFindClose lngFileHandle
>>> CopyFileToPocketPC = False
>>> End If
>>>
>>> 'create the file on the device, and return the handle to the file
>>> filename = ptxtPPCFile
>>> lngDestinationHandle = CeCreateFile(filename, GENERIC_WRITE,
>>> FILE_SHARE_READ, vbNullString, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
>>>
>>> 'if something went wrong in CeCreateFile we will get -1, and therefore
>>> need to abort
>>> If lngDestinationHandle = INVALID_HANDLE Then
>>> MsgBox "CeCreateFile Error " & CeGetLastError & " occurred.",
>>> vbCritical & vbOKOnly
>>> CopyFileToPocketPC = False
>>> CeCloseHandle lngDestinationHandle
>>> Exit Function
>>> End If
>>>
>>> 'Call function to read file on the desktop into the byte buffer
>>> If ReadFileAsBinary(ptxtDesktopFile, lngFileSize, bytBuffer()) = True
>>> Then
>>>
>>> 'Write contents of Binary buffer to CE file.
>>> 'Return value of 0 = failure, non zero = success
>>> intRetVal = CeWriteFile(lngDestinationHandle, bytBuffer(0), lngFileSize,
>>> lngNumBytesWritten, 0)
>>>
>>> If intRetVal = WRITE_ERROR Then
>>> GoTo ErrHandler
>>> End If
>>>
>>> End If
>>>
>>> CeCloseHandle lngDestinationHandle
>>>
>>> CopyFileToPocketPC = True
>>>
>>> Exit Function
>>>
>>> ErrHandler:
>>>
>>> MsgBox "Error " & CeGetLastError & " Occurred When Copying File " & _
>>> ptxtDesktopFile & " To The Device as " & ptxtPPCFile, vbCritical &
>>> vbOKOnly
>>>
>>> If lngDestinationHandle Or lngDestinationHandle <> INVALID_HANDLE Then
>>> CeCloseHandle lngDestinationHandle
>>> End If
>>> CopyFileToPocketPC = False
>>>
>>> End Function
>>>
>>>
>>> The function is called, for example,
>>> CopyFileToPocketPC("\Temp\toto.txt","C:\Temp\toto.txt")
>>>
>>>

>
> Yes I can explorer my temp folder and copy files.
>
> With an another mobile device(iPaq) it'ok but with an another(Psion
> workabout), I 've got the error on CECreateFile
>
> Where is the difference between this two devices?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
invalide menu handle error message =?Utf-8?B?bmVlZCBoZWxw?= Windows XP General 1 29th Sep 2006 07:36 AM
Invalide Argument =?Utf-8?B?TmVlZGhlbHA=?= Microsoft Access 2 18th Oct 2005 06:59 AM
WINDOWS 2000 Server - Invalide free space =?Utf-8?B?U2VyZ2V5?= Microsoft Windows 2000 File System 0 8th Jul 2004 08:04 AM
invalide coordinates cody Microsoft Dot NET Framework Forms 0 21st Feb 2004 12:36 AM
Invalide BlackWebApplication 137093 =?Utf-8?B?SnJkMDI2NA==?= Windows XP New Users 1 8th Jan 2004 04:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:33 PM.