Mobile anti-theft software implementation (source code)

Source: Internet
Author: User

Some time ago, my mother's mobile phone was stolen. In case of a theft, if my mobile phone was lost, it would be even more depressing. Remember that many mobile phones have the anti-theft function. If I change my SIM card, the new

The SIM card mobile phone number, GPS coordinates, and anything are sent to the bound mobile phone. I checked the information on the Internet, and there are a lot of such software. It was not very complicated to look at the functions, so I wrote a play on my own.

.

SDK Development Environment vs2008 wm6. Net CF 3.5

 

The implementation method is simple.
1. Each SIM has a unique imsi number. You can use the imsi number to determine whether the SIM card is replaced.
2. If it is detected that imsi is not your SIM card, you can confirm that others may be using your mobile phone.
3. Each time the boot program runs automatically, it detects that if someone else uses your mobile phone, it will automatically send his call records and GPS coordinates to the bound mobile phone number.
4. Find out the mobile phone number of the person using your mobile phone, recent call records, and GPS coordinates.

 

Code
1. Take the SIM card imsi number
Use controltapi. getimsinumber () in the tapilib. dll class library to get the SIM card imsi number.
2. Determine if it is your SIM card
String simstr = controltapi. getimsinumber ();
If (simstr. length! = 0)
{
If (simstr! = SIM)
{
Sim indicates the imsi number of your mobile phone card obtained in advance.

3. Retrieve the code of the recent call record
[Structlayout (layoutkind. Sequential)]
Public struct calllogentry
{
Public uint32 cbsize;
Public uint64 ftstarttime;
Public uint64 ftendtime;
Public short IOM;

Public bool foutgoing;
Public bool fconnected;
Public bool fended;

Public bool froam;
Public short CIDT;
Public intptr psznumber;
Public intptr pszname;
Public intptr psznametype;
Public intptr psznote;
};
[Dllimport ("phone. dll", entrypoint = "phoneopencalllog", setlasterror = true)] // you must first open the call record handle in phoneopencalllog.
Private Static extern int phoneopencalllog (ref intptr phandle );

[Dllimport ("phone. dll", entrypoint = "phoneclosecalllog", setlasterror = true)] // call phoneclosecalllog to close the handle
Private Static extern int phoneclosecalllog (intptr phandle );

[Dllimport ("phone. dll", entrypoint = "phonegetcalllogentry", setlasterror = true)]
Private Static extern int phonegetcalllogentry (intptr phandke, ref calllogentry pentry );
// The phonegetcalllogentry method returns a call record structure that contains information such as the number, name, call start time, and call end time.

Private string getlog ()
{
String callinfo = "";

Try
{
Intptr handle = intptr. Zero; // handle

Calllogentry entry = new calllogentry ();
Phoneopencalllog (ref handle); // you must first open the call record handle in phoneopencalllog.
Entry. cbsize = (uint) Marshal. sizeof (entry); // return the unmanaged size of the class

If (handle! = Intptr. Zero)
{
While (phonegetcalllogentry (handle, ref entry) = 0) // get call records
{// Character Al. ptrtostringuni
String phonenumber = marshal. ptrtostringuni (entry. psznumber); // number
String name = marshal. ptrtostringuni (entry. pszname); // name

If (phonenumber = NULL)
{
Phonenumber = string. empty;
}

If (name = NULL)
{
Name = string. empty;
}

String temp = (phonenumber. Trim () + name. Trim ());
Callinfo = callinfo + temp;
}
Phoneclosecalllog (handle );

If (callinfo. Length <140)
{
Return callinfo;
}
Else
{
Return callinfo. substring (0,140 );
}
}
Else
{
Int error = marshal. getlastwin32error ();
Return "";
}
}
Catch (exception EP)
{
// MessageBox. Show (Ep. tostring ());
Return "";
}
Finally
{
}

}
4. Get the GPS coordinate code
Gpsdevicestate device = NULL;
Gpsposition position = NULL;
GPS = new GPS ();

Void gps_devicestatechanged (Object sender, devicestatechangedeventargs ARGs)
{
Device = args. devicestate;
}

Protected void gps_locationchanged (Object sender, locationchangedeventargs ARGs)
{
Position = args. position;
STR = "";
If (position! = NULL)
{
// Dimension
If (position. latitudevalid)
{
STR + = position. Latitude;
}
// Longitude
If (position. longitudevalid)
{
STR + = "" + position. longpolling;

 

 

5. Send text message code
Smsmessage MSG = new smsmessage (phone, STR );
MSG. Send ();
6. package it as the boot program
When packaging the cab file, you only need to add the shortcut to the Startup Folder.

 

Weaknesses.
1. The GPS code is modified according to the SDK, but it is only for Satellite Positioning. I do not know how to implement it according to the base station positioning code. The coordinates can be sent only when the mobile phone user walks to the location where the satellite signal is good.

Go out
2. The GPS coordinates sent are just a general location, within a few hundred meters, some floating
3. If the mobile phone is restored to the factory settings or the phone is flushed, the program cannot run.

Even if the GPS signal is poor, you can only get the phone number of the person using the mobile phone. The call record is also very useful. The code is just written and playful. It provides the following code for reference.

If you find anything unreasonable, need to improve the place, or you have any better implementation method mail contact 328452421@qq.com (qq perennial not online, mail contact) Zhu Xiao (Taishan College ). Exchange with each other. Thank you.

 

Source http://download.csdn.net/source/3239409

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.