*Remote API Desktop*

Back to the start
Back to the libraries overview


Overview (RAPI Desktop)
Connect (RAPIDesktop)
Connected Event (RAPIDesktop)
CopyFileFromDevice1 (RAPIDesktop)
CopyFileFromDevice2 (RAPIDesktop)
CopyFileOnDevice (RAPIDesktop)
CopyFileToDevice1 (RAPIDesktop)
CopyFileToDevice2 (RAPIDesktop)
CreateDeviceDirectory (RAPIDesktop)
Disconnected Event (RAPIDesktop)
DeleteDeviceFile (RAPIDesktop)
DeviceFileExists (RAPIDesktop)
DeviceShell (RAPIDesktop)
GetFiles (RAPIDesktop)
GetFileSize (RAPIDesktop)
IsConnected (RAPIDesktop)
New1 (RAPIDesktop)


Overview (RAPI Desktop) Top

The RAPI library (Remote API) is a desktop-only library which allows communication between the desktop and the device using ActiveSync.
Using RAPI library you can transfer files between the device and the desktop, launch applications on the device from the desktop, and do other file operations.
The RAPI library - RAPIDesktop.dll is based on OpenNETCF.Desktop.Communication library.
To use these features both dll files: RAPIDesktop.dll and OpenNETCF.Desktop.Communcation.dll should be copied to the application folder (source code or compiled application).
The OpenNETCF.Desktop.Communcation library and its license agreement are included in this package.
Note that the device must be connected to the desktop using ActiveSync.

Example:
'Add a RAPIDesktop object named rapi.
Sub Globals

End Sub

Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
t = now '3 seconds timeout.
do until rapi.IsConnected = true
doevents
if (now - t)/cTicksPerSecond > 3 then
msgbox("Cannot connect to device.")
appclose
end if
loop
if rapi.DeviceFileExists("\My Documents\MyApp.exe") = true then
rapi.CopyFileToDevice1(AppPath & "\data.dat","\My Documents")
rapi.DeviceShell("MyApp.exe","")
end if
End Sub


Connect (RAPIDesktop) Top

Tries to open an asynchronously connection with the device.
The application will not stop waiting for the connection.
You can use the Connected and Disconnected events to do something after the connection or you can create a time limited loop which waits for the connection.
Syntax: Connect

Example: Connecting using a time limited loop.
'Add a RAPIDesktop object named rapi.
Sub Globals

End Sub

Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
t = now '3 seconds timeout.
do until rapi.IsConnected = true
doevents
if (now - t)/cTicksPerSecond > 3 then
msgbox("Cannot connect to device.")
appclose
end if
loop
if rapi.DeviceFileExists("\My Documents\MyApp.exe") = true then
rapi.CopyFileToDevice1(AppPath & "\data.dat","\My Documents")
rapi.DeviceShell("MyApp.exe","")
end if
End Sub

Example: Connecting using Connected event.


'Add a RAPIDesktop object named rapi.
Sub Globals

End Sub

Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
if rapi.DeviceFileExists("\My Documents\MyApp.exe") = true then
rapi.CopyFileToDevice1(AppPath & "\data.dat","\My Documents")
rapi.DeviceShell("MyApp.exe","")
end if
End Sub


Connected Event (RAPIDesktop) Top

Occurs after the creation of a successful connection.
Syntax: Connected
Example:
Sub rapi_Connected
...
End Sub


CopyFileFromDevice1 (RAPIDesktop) Top

Copies a file from the device to the desktop.
Syntax: CopyFileFromDevice (DeviceFile As String, DesktopPath As String)

Example:
'Add a RAPIDesktop object named rapi.
Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
rapi.CopyFileFromDevice1("\Windows\alarm1.wav",AppPath)
End Sub


CopyFileFromDevice2 (RAPIDesktop) Top

Copies a file from the device to the desktop allowing a different name for the target file.
Syntax: CopyFileFromDevice2 (DeviceFile As String, DesktopFile As String)

Example:
'Add a RAPIDesktop object named rapi.
Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
rapi.CopyFileFromDevice2("\Windows\alarm1.wav",AppPath & "\1.wav")
End Sub


CopyFileOnDevice (RAPIDesktop) Top

Creates a new copy of a file on the device (the source and the target files are on the device).
Syntax: CopyFileOnDevice (SourceFile As String, TargetFile As String)

Example:
'Add a RAPIDesktop object named rapi.
Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
rapi.CopyFileOnDevice("\my documents\1.txt", "\my documents\2.txt")
End Sub


CopyFileToDevice1 (RAPIDesktop) Top

Copies a file from the desktop to the device.
Syntax: CopyFileToDevice1 (DesktopFile As String, DevicePath As String)

Example:
'Add a RAPIDesktop object named rapi.
Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
rapi.CopyFileToDevice1(AppPath & "\1.txt","\My Documents")
End Sub


CopyFileToDevice2 (RAPIDesktop) Top

Copies a file from the desktop to the device allowing a different name for the target file.
Syntax: CopyFileToDevice2 (DesktopFile As String, DeviceFile As String)

Example:
'Add a RAPIDesktop object named rapi.
Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
rapi.CopyFileToDevice2(AppPath & "\1.txt","\My Documents\NewFile.txt")
End Sub


CreateDeviceDirectory (RAPIDesktop) Top

Creates a new folder on the device.
Syntax: CreateDeviceDirectory (path As String)

Example:
'Add a RAPIDesktop object named rapi.
Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
rapi.CreateDeviceDirectory("\My Documents\New Folder")
End Sub


Disconnected Event (RAPIDesktop) Top

Occurs when the connection is disconnected.
Syntax: Disconnected

Example:
Sub rapi_Disconnected
...
End Sub


DeleteDeviceFile (RAPIDesktop) Top

Deletes a file on the device.
Syntax: DeleteDeviceFile (file As String)


DeviceFileExists (RAPIDesktop) Top

Checks whether a specific file exists on the device.
Syntax: DeviceFileExists (file As String) As Boolean

Example:
Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
if rapi.DeviceFileExists("\My Documents\MyApp.exe") = true then
rapi.CopyFileToDevice1(AppPath & "\data.dat","\My Documents")
rapi.DeviceShell("MyApp.exe","")
end if
End Sub


DeviceShell (RAPIDesktop) Top

Launches an application on the device.
Syntax: DeviceShell (file As String, CommandLine As String)

Example:
'Add a RAPIDesktop object named rapi.
Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
rapi.DeviceShell("pxl","\My Documents\test.xls") 'Opens Pocket Excel with the specified work book.
End Sub


GetFiles (RAPIDesktop) Top

Returns an array of file names matching the SearchPattern specified.
Syntax: GetFiles (SearchPattern As String) As String()


SearchPattern - The folder path which GetFiles will search in.
SearchPattern can include wildcards.
Note: GetFiles will return both files and folders matching the search pattern.

Example:
'Add a RAPIDesktop object named rapi.
Sub Globals
dim files(0) as String
End Sub

Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
files() = rapi.GetFiles("\SD card\*.*")
msgbox(ArrayLen(files()) & " files found.")
msgbox("First file: " & files(0))
msgbox("Last file: " & files(ArrayLen(files())-1))
End Sub


GetFileSize (RAPIDesktop) Top

Returns the size of the specified file.
Syntax: GetFileSize (DeviceFile As String) As Int64
GetFileSize will return -1 for folders.

Example:
'Add a RAPIDesktop object named rapi.
Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
End Sub

Sub rapi_Connected
msgbox(rapi.GetFileSize("\My Documents\1.txt"))
End Sub


IsConnected (RAPIDesktop) Top

Returns true if a successful connection was created.
Syntax: IsConnected

Example:
Sub App_Start
Form1.Show
rapi.New1
rapi.Connect
t = now '3 seconds timeout.
do until rapi.IsConnected = true
doevents
if (now - t)/cTicksPerSecond > 3 then
msgbox("Cannot connect to device.")
appclose
end if
loop
if rapi.DeviceFileExists("\My Documents\MyApp.exe") = true then
rapi.CopyFileToDevice1(AppPath & "\data.dat","\My Documents")
rapi.DeviceShell("MyApp.exe","")
end if
End Sub


New1 (RAPIDesktop) Top

Initializes a RAPI object.
Syntax: New