Launching an Application
There are many reasons to enable you to start an app on your device from a desktop program. In the case, you can use this technology:
· Install a new version of the app. Simply copy the CAB file to the device and then run the CAB installer on your device to provide installation. This technology is often used in the case where you want to automatically publish and install application updates.
Note Another similar issue is the installation process of the automatic table-sided installation, using the ActiveSync built-in function.
· Repends your mobile app after installation of the new version of the application.
· Start a device application to process new updated data, after updating the text or XML file.
The RAPI sample program is shown in Figure 4.
Figure 4. The launch application tab of the rapi demo program
OpenNetcf.desktop.communication Namespace RAPI class provides the createProcess method to launch a device file. The device application you want to start is the first parameter of the method. You can pass a command line to the application as the second parameter.
Click event in the BTnlaunchperform button demonstrates the CreateProcess method.
[Vc # .NET]
Private void btnlaunchPerform_Click (Object Sender, System.EventArgs E)
{
// perform the launch.
Try
{
IF (txtlaunchfile.text == "")
{
MessageBox.show ("You Must Provide a File to Launch.",
"No file provided");
}
Else
{
Myrapi.createProcess (txtlaunchfile.text, txtlaunchcommand.text);
MessageBox.show ("Your File Has Been Launched.", "Launch Success");
}
}
// Handle Any Errors That Might OCCUR.
Catch (Exception EX)
{
Messagebox.show ("The Following Error Occurred While Launching The
File - "
EXMESSAGE, "launch error");
}
}
[Vb.net]
Private sub btnlaunchPerform_Click (Byval Sender As System.Object, ByVal
e as system.eventargs Handles btnlaunchperform.click
'Perform the launch.
Try
IF (txtlaunchfile.text = ")")
MessageBox.show ("You Must Provide a File to Launch.", _ "No file provided");
}
Else
"No file provided");
}
Else
{
Myrapi.createProcess (txtlaunchfile.text, txtlaunchcommand.text);
MessageBox.show ("Your File Has Been Launched.", "Launch Success");
}
}
// Handle Any Errors That Might OCCUR.
Catch (Exception EX)
{
Messagebox.show ("The Following Error Occurred While Launching The
File - "
EXMESSAGE, "launch error");
}
}
[Vb.net]
Private sub btnlaunchPerform_Click (Byval Sender As System.Object, ByVal
e as system.eventargs Handles btnlaunchperform.click
'Perform the launch.
Try
IF (txtlaunchfile.text = ")")
Messagebox.show ("You Must Provide a File to Launch.", _
"No file provided")
EXIT SUB
END IF
Myrapi.createProcess (txtlaunchfile.text, txtlaunchcommand.text)
MessageBox.show ("Your File Has Been Launched.", "Launch Success")
'Handle Any Errors That Might Occur.
Catch exception
Messagebox.show ("The Following Error Occurred While Launching The File
- "& ex.Message, _
"Launch error")
END TRY
End Sub
Next we will enter the topic related to the last RAPI: obtain system information. In the section below, you will see that the RAPI class provides some ways to get detailed information for the connection device. Retrieving System Information
Get the specified device system information allows your program to deliver content or change in the following aspects:
• The processor used on the device, when the application is uploaded to the CAB file to the file containing the specified processor to the device.
Note that the most common environment for this technology is when you publish applications to earlier versions of Pocket PC devices, such as Windows Mobile devices based on ARM processors.
· Operating system version running on the connection device, updating the corresponding file according to the processor type.
• Connect the power of the device, often used to warn their devices in a low power state before the user enters the area.
· Connect the memory status of the device to detect if the data can be downloaded, if the user downloads unauthorized applications or other memory related functions, or to determine if you have enough space to install the application update.
This part of the presentation presentation shows Figure 5.
Figure 5. The Device Information Tab of the Rapi Demo Program
The RAPI class provides four ways to get this information, getDeviceSystemInfo (processor type), getDeviceversion, getDeviceSystemPowerStatus (power status), and getDeviceMemoryStatus.
These methods are demonstrated by clicking the BTNINFORETRIEVE button.
[Vc # .NET]
Private void btninforetrieve_click (Object sender, system.eventargs e) {
String info;
MemoryStatus MS;
System_info si;
SYSTEM_POWER_STATUS_EX SPS;
OsversionInfo Vi;
// Retrieve The System Information.
Myrapi.getDeviceSystemInfo (Out Si);
// Retrieve The Device OS Version Number.
Myrapi.GetDeviceVersion (OUT VI);
// Retrieve The Device Power Status.
Myrapi.GetDeviceSystemPowerStatus (Out SPS);
// Retrieve The Device Memory Status.
Myrapi.getDeviceMemoryStatus (OUT MS);
// Format the Retrieved Information.
INFO = "The Connected Device Has An";
Switch (Si.WProcessorArchitecture)
{
Case ProcessRarchitecture.intel:
INFO = "Intel processor./N";
Break;
Case ProcessRarchitecture.Mips:
INFO = "MIPS Processor./N";
Break;
Case ProcessRarchitecture.Arm:
INFO = "ARM Processor./N";
Break;
DEFAULT:
INFO = "Unknown Processor Type./N";
Break;
}
INFO = "OS Version:" vi.dwmajorversion "."
vi.dwminorversion "."
vi.dwbuildnumber "/ n";
IF (sps.aclinestatus == 1)
{
INFO = "on ac Power: YES / N";
}
Else
{
INFO = "on ac Power: no / n";
}
INFO = "Battery level:" SPS.BatterylifePercent "% / N";
INFO = "Total Memory:" string.format ("{0: ###, ###, ###}",
Ms.dwtotalphys)
"/ n";
// Display the results.
lblinfo.text = info;
}
[Vb.net]
Private sub btninforetrieve_click (Byval Sender as system.object, byval
e as system.eventargs) Handles btninforetrieve.click
DIM INFO AS STRING
DIM MS AS New MemoryStatus
DIM SI AS New System_info
DIM SPS AS NEW SYSTEM_POWER_STATUS_EXDIM VI AS New OsversionInfo
'Retrieve the system information.
Myrapi.GetDeviceSystemInfo (Si)
'Retrieve The Device OS Version Number.
Myrapi.GetDeviceVersion (VI)
'Retrieve The Device Power Status.
Myrapi.GetDeviceSystemPowerStatus (SPS)
'Retrieve The Device Memory Status.
Myrapi.GetDeviceMemoryStatus (MS)
'Format the retrieved information.
INFO = "The connection device Has AN"
Select Case Si.WProcessRarchitecture
Case ProcessRecchitecture.intel
INFO = "Intel processor." & vbcrlf
Case ProcessRarchitecture.MIPS
INFO = "MIPS Processor." & vbcrlf
Case ProcessRarchitecture.Arm
INFO = "ARM Processor." & vbcrlf
Case Else
INFO = "Unknown Processor Type." & vbrlf
End SELECT
INFO = "OS Version:" & vi.dwmajorversion & "& vi.dwminorversion
& "& vi.dwbuildnumber & vbcrlf
INFO = "on ac Power:" & Iif (sps.aclinestatus = 1, "yes", "no")
& vbcrlf
Info = "Battery Level:" & SPS.BatterylifePercent & "%" & VBCRLF
INFO = "Total Memory:" & string.format ("{0: ###, ###, ###}",
Ms.dwtotalphys & vbcrlf
'Display the results.
lblinfo.text = info
End Sub
Here we add desktop applications to your mobile solution and the introduction to the Remote API, you have to say paragraph. I suggest you spend some time to verify other features provided by the OpenNetcf.Desktop.communication namespace. Remember, that is all the operations, the OpenNetCF namespace provides a variety of operations for your application.
Back on the road
It is another new month. Spring has come to every corner, I have to take my waterpipe and Pocket PC to the sun's sufficient florida. In my next article, we will test more about mobile developers.