Copying files to pda: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 86: Line 86:


Basically it initialises RAPI, creates the file on the PDA, reads from the local file and writes the the file on the PDA!
Basically it initialises RAPI, creates the file on the PDA, reads from the local file and writes the the file on the PDA!
[[Category:Code Examples]]

Revision as of 09:27, 9 September 2005

Description

This script shows you how to "copy" a file from a desktop machine to a PDA using RAPI.

The Function

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 'FileName' r
IfErrors done
 
FileRead $0 $1
 
;Get the lenght of the string read
StrLen $2 $1
 
;----------------------
;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"
 
;----------------------
;Dll Call Structure
;
;BOOL CeCloseHandle( 
;  HANDLE hObject
;); 
 
done:
 
;Close the file on the PDA
System::Call "rapi::CeCloseHandle(i r10) i .r1"
 
;Close the local file
FileClose $0
 
 System::Free 0
FunctionEnd

Basically it initialises RAPI, creates the file on the PDA, reads from the local file and writes the the file on the PDA!