Click here to Skip to main content
15,886,075 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hi guys,

I'm new to programming. I work for a research in Sri Lanka.

In our research data is collected on windows mobile devices. I am the person who connects the devices (Known as JUNOs) and copy the data to the hard drive. But when I'm not around others should copy the data. But they haven't got IT knowledge.

I want to create a simple software which detects the JUNOs when connected, show a message that a device is connected(Ex : JUNO1 is now connected), and then a button to copy and paste data to hard disk. (Ex: Press copy button to copy data)

So if anyone can help me with this with the code it would be really helpful.
Thank you

[Edit(YR): spaces are free ;)]
Posted
Updated 25-Nov-11 18:06pm
v2

1 solution

May be i am a little late, but i have just seen this post now ...

You should take a look at RAPI (Remote API). There is a C# implementation on this site :http://rapi.codeplex.com/[^].

Using this API, you will able to create a program that detect any windows mobile (or windows CE) that connect on an usb port, and automatically copy data from it to the desktop computer.
As i remember, there is a simple demo with the code, and it is really simple.

Romain TAILLANDIER.
 
Share this answer
 
Comments
Janaka Medawala 9-Dec-11 11:36am    
Thank you so much sir for replying.But I cant seem to find any coding.Im fairly new to programming.Can you please guide me to a documentation of somekind? I would be truly greatfull to you
Romain TAILLANDIER 12-Dec-11 4:37am    
OK, i have simplified a small synchronizer just for you.
Create a new C# project, add a reference to OpenNetCfDesktop, and this class :
(Don't forget to install Active sync, or Manager for mobile device (not sure of the exact english name)).

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenNETCF.Desktop.Communication;
using System.IO;
using System.Diagnostics;

namespace RomainTAILLANDIER
{


public delegate void GenericHandler<t>(T param);
public delegate void VoidHandler();
public delegate int GenericHandlerWithResult<t>(T param);

public class SynchronizerSimple : Form
{

[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new RomainTAILLANDIER.SynchronizerSimple());
}

#region privates variables

///
/// Connection on Remote API.
///

private RAPI MyRapi;
///
/// if synchro is running
///

private bool SyncIsRunning = false;
///
/// start of battery load
///

public DateTime StartLoadingBattery;
///
/// end of batteryload
///

public DateTime EndLoadingBattery;


#endregion

#region construction

public SynchronizerSimple()
{
try
{
// Init Prop
InitializeComponent();



// Init RAPI
this.MyRapi = new RAPI();
// eveneemnt rapi
this.MyRapi.ActiveSync.Active += new ActiveHandler(this.ActiveSync_Active);
this.MyRapi.ActiveSync.Disconnect += new DisconnectHandler(this.ActiveSync_Disconnect);
this.MyRapi.ActiveSync.Listen += new ListenHandler(this.ActiveSync_Listen);
this.MyRapi.ActiveSync.Answer += new AnswerHandler(this.ActiveSync_Answer);

//this.MyRapi.RAPIConnected += new RAPIConnectedHandler(MyRapi_RAPIConnected);
//this.MyRapi.RAPIDisconnected += new RAPIConnectedHandler(MyRapi_RAPIDisconnected);
}
catch(Exception e)
{
Console.WriteLine(e);
}
}

///
/// on start
///

/// <param name="sender"></param>
/// <param name="e"></param>
private void SynchronizerSimple_Load(object sender, EventArgs e)
{
if(this.MyRapi != null)
{
// Si un PDA est connecté, on fait une connection
if(this.MyRapi.DevicePresent)
{
// on tente une reco
this.MyRapi.Connect();
this.EnableSyncBouttons(this.MyRapi.Connected);
}
else // sinon, on réduit
{
this.Minimize();
}
}
}


///
/// Variable nécessaire au concepteur.
///

private System.ComponentModel.IContainer components = null;

///
/// Nettoyage des ressources utilisées.
///

/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Code généré par le Concepteur Windows Form

///
/// Méthode requise pour la prise en charge du concepteur - ne modifiez
Romain TAILLANDIER 12-Dec-11 4:38am    
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SynchronizerSimple));
this.btnMinimize = new System.Windows.Forms.Button();
this.MyProgressBar = new System.Windows.Forms.ProgressBar();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.btnSyncUP = new System.Windows.Forms.Button();
this.MyNotifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.réduireToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.agrandireToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.quitterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.lblStatus = new System.Windows.Forms.Label();
this.lblActivity = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.btnQuit = new System.Windows.Forms.Button();
this.contextMenuStrip1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// btnMinimize
//
this.btnMinimize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnMinimize.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnMinimize.Location = new System.Drawing.Point(77, 287);
this.btnMinimize.Name = "btnMinimize";
this.btnMinimize.Size = new System.Drawing.Size(75, 23);
this.btnMinimize.TabIndex = 2;
this.btnMinimize.Text = "Minimize";
this.toolTip1.SetToolTip(this.btnMinimize, "Minimize");
this.btnMinimize.UseVisualStyleBackColor = true;
this.btnMinimize.Click += new System.EventHandler(this.btnReduire_Click);
//
// MyProgressBar
//
this.MyProgressBar.Location = new System.Drawing.Point(6, 167);
this.MyProgressBar.Name = "MyProgressBar";
this.MyProgressBar.Size = new System.Drawing.Size(321, 23);
this.MyProgressBar.TabIndex = 3;
this.toolTip1.SetToolTip(this.MyProgressBar, "avancement de la synchronisation");
//
// btnSyncUP
//
this.btnSyncUP.Enabled = false;
this.btnSyncUP.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnSyncUP.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.btnSyncUP.Location = new System.Drawing.Point(12, 9);
this.btnSyncUP.Name = "btnSyncUP";
this.btnSyncUP.Size = new System.Drawing.Size(333, 70);
this.btnSyncUP.TabIndex = 0;
this.btnSyncUP.Text = "Export";
this.btnSyncUP.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.toolTip1.SetToolTip(this.btnSyncUP, "Get data from device");
this.btnSyncUP.UseVisualStyleBackColor = true;
this.btnSyncUP.Click += new System.EventHandler(this.btnSyncUP_Click);
//
// MyNotifyIcon
//
this.MyNotifyIcon.ContextMenuStrip = this.contextMenuStrip1;
this.MyNotifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("MyNotifyIcon.Icon")));
this.MyNotifyIcon.Text = "Synchronizer";
this.MyNotifyIcon.Visible = true;
this.MyNotifyIcon.DoubleClick += new System.EventHandler(this.ctxAgrandir_Click
Romain TAILLANDIER 12-Dec-11 4:39am    
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.réduireToolStripMenuItem,
this.agrandireToolStripMenuItem,
this.quitterToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(125, 70);
//
// réduireToolStripMenuItem
//
this.réduireToolStripMenuItem.Name = "réduireToolStripMenuItem";
this.réduireToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.réduireToolStripMenuItem.Text = "minimize";
this.réduireToolStripMenuItem.Click += new System.EventHandler(this.btnReduire_Click);
//
// agrandireToolStripMenuItem
//
this.agrandireToolStripMenuItem.Name = "agrandireToolStripMenuItem";
this.agrandireToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.agrandireToolStripMenuItem.Text = "maximize";
this.agrandireToolStripMenuItem.Click += new System.EventHandler(this.ctxAgrandir_Click);
//
// quitterToolStripMenuItem
//
this.quitterToolStripMenuItem.Name = "quitterToolStripMenuItem";
this.quitterToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.quitterToolStripMenuItem.Text = "quit";
this.quitterToolStripMenuItem.Click += new System.EventHandler(this.Quitter_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.lblStatus);
this.groupBox1.Controls.Add(this.lblActivity);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.MyProgressBar);
this.groupBox1.Location = new System.Drawing.Point(12, 85);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(333, 196);
this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Synchronization";
this.groupBox1.Visible = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.ForeColor = System.Drawing.Color.MediumBlue;
this.label2.Location = new System.Drawing.Point(6, 89);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(63, 13);
this.label2.TabIndex = 6;
this.label2.Text = "Actual state";
//
// lblStatus
//
this.lblStatus.AutoEllipsis = true;
this.lblStatus.ForeColor = System.Drawing.Color.MediumBlue;
this.lblStatus.Location = new System.Drawing.Point(24, 104);
this.lblStatus.Name = "lblStatus";
this.lblStatus.Size = new System.Drawing.Size(303, 38);
this.lblStatus.TabIndex = 7;
this.lblStatus.Text = "not connected";
//
// lblActivity
//
this.lblActivity.AutoEllipsis = true;
this.lblActivity.ForeColor = System.Drawing.Color.MediumBlue;
this.lblActivity.Location = new System.Drawing.Point(24, 38);
this.lblActivity.Name = "lblActivity";
this.lblActivity.Size = new System.Drawing.Size(303, 37);
this.lblActivity.TabIndex = 4;
this.lblActivity.Text = "nothing";
//
// label1
//
this.label1.AutoSize = true;
this.label1.ForeColor = System.Drawing.Color.MediumBlue;
this.label1.Location = new System.Drawing.Point(6, 23);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 13);
Romain TAILLANDIER 12-Dec-11 4:40am    
this.label1.TabIndex = 5;
this.label1.Text = "Activity";
//
// btnQuit
//
this.btnQuit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnQuit.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnQuit.Location = new System.Drawing.Point(177, 287);
this.btnQuit.Name = "btnQuit";
this.btnQuit.Size = new System.Drawing.Size(75, 23);
this.btnQuit.TabIndex = 2;
this.btnQuit.Text = "Quit";
this.toolTip1.SetToolTip(this.btnQuit, "exit the program");
this.btnQuit.UseVisualStyleBackColor = true;
this.btnQuit.Click += new System.EventHandler(this.Quitter_Click);
//
// SynchronizerSimple
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(357, 322);
this.ControlBox = false;
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.btnQuit);
this.Controls.Add(this.btnMinimize);
this.Controls.Add(this.btnSyncUP);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "SynchronizerSimple";
this.Text = "Synchronisation ";
this.Load += new System.EventHandler(this.SynchronizerSimple_Load);
this.contextMenuStrip1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Button btnSyncUP;
private System.Windows.Forms.Button btnMinimize;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.ProgressBar MyProgressBar;
private System.Windows.Forms.NotifyIcon MyNotifyIcon;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem réduireToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem agrandireToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem quitterToolStripMenuItem;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label lblStatus;
private System.Windows.Forms.Label lblActivity;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnQuit;

#endregion

#region active sync events

///
/// Active sync est en train de répondre
///

private void ActiveSync_Answer()
{
this.Restore();
this.ShowActivity("Connection au PDA");
this.ShowStatus("running ...");
Console.WriteLine("AS Answer");
}

///
/// Active sync vient de se déco
///

private void ActiveSync_Disconnect()
{
this.MyRapi.Disconnect();


// on a déco le PDA, alors que la synchro était en cours.
if(this.SyncIsRunning)
{
// Log une erreur
Console.WriteLine("unwaited disconnect while synchronizing");
}
else
{

Console.WriteLine("AS disconnected");
}

// Battery Load Time
this.EndLoadingBattery = DateTime.Now;
TimeSpan BatteryLoadTime = EndLoadingBattery - StartLoadingBattery;
Console.WriteLine("Battery load time : " + BatteryLoadTime.TotalHours.ToStrin

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900