Archive: Pocket PC Installer - File and Directory creation


Pocket PC Installer - File and Directory creation
Hello Forum,


Sorry, if this is a post, that was made before, but I still have no solution found for my problem.

I want to write an installer which can copy files from the PC to the PDA. I used the code for copying files, which is published in the wiki, but still having the problem, that the files are created but never filled with the right content.

Here's an extract of me scripting code:

;create the file on the PDA
System::Call "rapi::CeCreateFile(w '\filename.txt', i 0x80000000|0x40000000, i 0, i 0, i 2, i 0x80, i 0) i .r10"

;Write your data across. Can be done in a loop etc.
FileOpen $0 'D:\filename.txt' r
MessageBox MB_OK|MB_ICONSTOP '$0'

FileRead $0 $1

;Get the length of the string read
StrLen $2 $1

MessageBox MB_OK|MB_ICONSTOP '$2'

;----------------------
;Dll Call Structure
;
;BOOL CeWriteFile(
; HANDLE hFile,
; LPCVOID lpBuffer,
; DWORD nNumberOfBytesToWrite,
; LPDWORD lpNumberOfBytesWritten,
; LPOVERLAPPED lpOverlapped
;);

System::Call "rapi::CeWriteFile(i r10., t r1, i r2, i 0, i 0) i .r11"


Does anybody see the error in the code? The file is always created but never filled with the right content. There is a file with name filename.txt with a size of 0Byte.
The registers in code are filled with the content, I just checked that with the messageboxes, but the file keeps to be empty.

Please help me


Thank you


Could be that you're sending a null pointer for lpNumberOfBytesWritten. You might need to change that 4th parameter to "i .r3" for example.


Thank you for your reply, I tried your suggestion, but the result is still the same. Only a file with 0 Bytes is created.

I had the same idea, that there should be a problem with the pointer in the system call, but I can't find any solution.

Looks like the content is never written to the file.


Have you tried checking what it outputs for number of bytes written or calling CeGetLastError?


Used the following code to get the contents of the registers

[I]MessageBox MB_OK|MB_ICONSTOP '$1'
MessageBox MB_OK|MB_ICONSTOP '$2'

System::Call "rapi::CeWriteFile(i r10., t r1, i r2, i 0, i 0) i .r11"

System::Call "rapi::CeGetLastError() i .r6"

MessageBox MB_OK|MB_ICONSTOP '$6'[\I]

In the register $1 and $2 the content is ok, but the last ce error is the 87, which stands for wrong parameter.
So your assumption was correct the parameters are not the right ones.


You passed NULL for lpNumberOfBytesWritten which doesn't support this according to the documentation. Pass `*i .r3` instead.


Just thought that r2 stands for $2. I wrote the string length in this register. But also with '*i .r3' parameter results in an 87 error. Still the same problem. For better understanding I post the whole code one more time:

Function createSettingsFile
;Init RAPI

;----------------------
;Dll Call Structure
;
;HRESULT CeRapiInit(void);
System::Call "rapi::CeRapiInit() i .r0"

;Create the file on the PDA

;----------------------
;Dll Call Structure
;
;HANDLE CeCreateFile(
; LPCWSTR lpFileName,
; DWORD dwDesiredAccess,
; DWORD dwShareMode,
; LPSECURITY_ATTRIBUTES lpSecurityAttributes,
; DWORD dwCreationDisposition,
; DWORD dwFlagsAndAttributes,
; HANDLE hTemplateFile
;);
;
; Access Mode Values :
; GENERIC_READ = 0x80000000;
; GENERIC_WRITE = 0x40000000;
;
; Creation Disposition Value :
; CREATE_NEW = 1;
; CREATE_ALWAYS = 2;
; OPEN_EXISTING = 3;
;
; Flag and attribute values
; FILE_ATTRIBUTE_NORMAL = 0x80;
; FILE_ATTRIBUTE_DIRECTORY = 0x10;
; FILE_ATTRIBUTE_TEMPORARY = 0x100;

System::Call "rapi::CeCreateFile(w '\filename.txt', i 0x80000000|0x40000000, i 0, i 0, i 2, i 0x80, i 0) i .r10"

;Write your data across. Can be done in a loop etc.
FileOpen $0 'D:\workspace\filename.txt' r
;MessageBox MB_OK|MB_ICONSTOP '$0'
;IfErrors done

FileRead $0 $1

;Get the length of the string read
StrLen $2 $1

;MessageBox MB_OK|MB_ICONSTOP '$2'

;----------------------
;Dll Call Structure
;
;BOOL CeWriteFile(
; HANDLE hFile,
; LPCVOID lpBuffer,
; DWORD nNumberOfBytesToWrite,
; LPDWORD lpNumberOfBytesWritten,
; LPOVERLAPPED lpOverlapped
;);

MessageBox MB_OK|MB_ICONSTOP '$1'
MessageBox MB_OK|MB_ICONSTOP '$2'

System::Call "rapi::CeWriteFile(i r10., t r1, *i .r3, i 0, i 0) i .r11"

System::Call "rapi::CeGetLastError() i .r6"

MessageBox MB_OK|MB_ICONSTOP '$6'

;----------------------
;Dll Call Structure
;
;BOOL CeCloseHandle(
; HANDLE hObject
;);

;Close the file on the PDA
System::Call "rapi::CeCloseHandle(i r10) i .r1"

;Close the local file
FileClose $0

System::Free 0
FunctionEnd


The example returns me the error 87 in the last message box. Can anybody help me??????


Thanks

You still pass 0 as lpNumberOfBytesWritten only now you also pass a pointer instead of the number of bytes to write in nNumberOfBytesToWrite.


Sorry, my fault!!!!


Thank you very much, now it is working.


For all, who have problems with the example on the homepage, the right call of the ceWriteFile is:

System::Call "rapi::CeWriteFile(i r10., t r1, i r2, *i .r3, i 0) i .r11"


Thanks to all, who helped me!!


hello
I am new for this installation process.
I am using same function for transferring the file to Windows mobile device. It is transferring the file but with few data. Can you please help me out? I think i need to write loop over there while reading the file.

Thank you