Disable ‘Flight Mode’ using C#.NET CompactFramework on Windows Mobile 5 Devices
After spending way too long looking for what should be an easy answer, I ended up finding out a relatively easy way to do it. Rather than add to the cryptic nonsense replies you will find all over the web when trying to find a way to just turn flight mode off programmatically, I thought I'd make a blog and post the answer here.
Basically a nice gent called Alex Feinman has created a wrapper class. I found out this information at the OpenNetCF Forums. I have also uploaded the zip archive mentioned in that thread in case it is no longer available by the time you're reading this.
In my code I have set up two very easy and simple basic functions. One to turn Flight Mode on, and one to turn it off.
private void DisableFlightMode()
{
Tapi tapi = new Tapi();
tapi.Initialize();
thisLine = GetCellLine(tapi);
if (thisLine == null) return;
CellTSP.lineSetEquipmentState(thisLine.hLine, (int)LINEEQUIPSTATE.FULL);
CellTSP.lineRegister(thisLine.hLine, (int)LINEREGMODE.AUTOMATIC, "", 0);
thisLine.Dispose();
tapi.Shutdown();
}
private void EnableFlightMode()
{
Tapi tapi = new Tapi();
tapi.Initialize();
thisLine = GetCellLine(tapi);
if (thisLine == null) return;
CellTSP.lineSetEquipmentState(thisLine.hLine, (int)LINEEQUIPSTATE.MINIMUM);
thisLine.Dispose();
tapi.Shutdown();
}
private Line GetCellLine(Tapi tapi)
{
for (int count = 0; count <tapi.NumDevices; count++)
{
try
{
LINEDEVCAPS dc = new LINEDEVCAPS(1024);
dc.Store();
int dwVersion = tapi.NegotiateVersion(count);
NativeTapi.lineGetDevCaps(tapi.hLineApp, count, dwVersion, 0, dc.Data);
dc.Load();
if (dc.LineName == CellTSP.CELLTSP_LINENAME_STRING)
{
return tapi.CreateLine(count, LINEMEDIAMODE.INTERACTIVEVOICE, LINECALLPRIVILEGE.OWNER);
}
}
catch { }
}
return null;
}
Please keep in mind that these functions simply enable or disable flight mode. If you disable flight mode, don't expect the phone features to be instantly available. Your device still needs to connect to the mobile phone tower, which could take around 30 seconds.
Enjoy!

on April 6th, 2007 at 6:05 pm
This is very useful, thanks for posting. If you are nearby I’ll buy you a beer , if not……do you have a paypal account
on April 7th, 2007 at 8:13 pm
[…] but Mark over at longshadow has saved some more effort, why reinvent the wheel - take a look at Marks Blog at Longshadow and OpenNetCF […]
on September 25th, 2007 at 8:13 pm
I think I love you. You may have just saved me from a rage-based brain anurism.
Thanks so much!
on July 6th, 2008 at 5:52 am
I’m a rookie with this kinda stuff, but how do I use this code to turn off/on flight mode? I see the code, but how do I create the file to disable/enable flight mode?