[Windows Mobile Apps and Games] kuzco1:
Hi,

hm , i can access this site without any problem.

Enclosed the code from dlane:

using System;

using System.Threading;

using System.Runtime.InteropServices;

namespace CellId

{

public class RIL

{

// string used to store the CellID string

private static string celltowerinfo = "";

/*

* Uses RIL to get CellID from the phone.

*/

public static string GetCellTowerInfo()

{

// initialise handles

IntPtr hRil = IntPtr.Zero;

IntPtr hRes = IntPtr.Zero;

// initialise result

celltowerinfo = "";

// initialise RIL

hRes = RIL_Initialize(1, // RIL port 1

new RILRESULTCALLBACK(rilResultCallback), // function to call with result

null, // function to call with notify

0, // classes of notification to enable

0, // RIL parameters

out hRil); // RIL handle returned

if (hRes != IntPtr.Zero)

{

return "Failed to initialize RIL";

}

// initialised successfully

// use RIL to get cell tower info with the RIL handle just created

hRes = RIL_GetCellTowerInfo(hRil);

// wait for cell tower info to be returned

waithandle.WaitOne();

// finished - release the RIL handle

RIL_Deinitialize(hRil);

// return the result from GetCellTowerInfo

return celltowerinfo;

}

// event used to notify user function that a response has

// been received from RIL

private static AutoResetEvent waithandle = new AutoResetEvent(false);

public static void rilResultCallback(uint dwCode,

IntPtr hrCmdID,

IntPtr lpData,

uint cbData,

uint dwParam)

{

// create empty structure to store cell tower info in

RILCELLTOWERINFO rilCellTowerInfo = new RILCELLTOWERINFO();

// copy result returned from RIL into structure

Marshal.PtrToStructure(lpData, rilCellTowerInfo);

// get the bits out of the RIL cell tower response that we want

celltowerinfo = rilCellTowerInfo.dwCellID + "-" +

rilCellTowerInfo.dwLocationAreaCode + "-" +

rilCellTowerInfo.dwMobileCountryCode;

// notify caller function that we have a result

waithandle.Set();

}

// -------------------------------------------------------------------

// RIL function definitions

// -------------------------------------------------------------------

/*

* Function definition converted from the definition

* RILRESULTCALLBACK from MSDN:

*

* http://msdn2.microsoft.com/en-us/library/aa920069.aspx

*/

public delegate void RILRESULTCALLBACK(uint dwCode,

IntPtr hrCmdID,

IntPtr lpData,

uint cbData,

uint dwParam);

/*

* Function definition converted from the definition

* RILNOTIFYCALLBACK from MSDN:

*

* http://msdn2.microsoft.com/en-us/library/aa922465.aspx

*/

public delegate void RILNOTIFYCALLBACK(uint dwCode,

IntPtr lpData,

uint cbData,

uint dwParam);

/*

* Class definition converted from the struct definition

* RILCELLTOWERINFO from MSDN:

*

* http://msdn2.microsoft.com/en-us/library/aa921533.aspx

*/

public class RILCELLTOWERINFO

{

public uint cbSize;

public uint dwParams;

public uint dwMobileCountryCode;

public uint dwMobileNetworkCode;

public uint dwLocationAreaCode;

public uint dwCellID;

public uint dwBaseStationID;

public uint dwBroadcastControlChannel;

public uint dwRxLevel;

public uint dwRxLevelFull;

public uint dwRxLevelSub;

public uint dwRxQuality;

public uint dwRxQualityFull;

public uint dwRxQualitySub;

public uint dwIdleTimeSlot;

public uint dwTimingAdvance;

public uint dwGPRSCellID;

public uint dwGPRSBaseStationID;

public uint dwNumBCCH;

}

// -------------------------------------------------------------------

// RIL DLL functions

// -------------------------------------------------------------------

/* Definition from: http://msdn2.microsoft.com/en-us/library/aa919106.aspx */

[DllImport("ril.dll")]

private static extern IntPtr RIL_Initialize(uint dwIndex,

RILRESULTCALLBACK pfnResult,

RILNOTIFYCALLBACK pfnNotify,

uint dwNotificationClasses,

uint dwParam,

out IntPtr lphRil);

/* Definition from: http://msdn2.microsoft.com/en-us/library/aa923065.aspx */

[DllImport("ril.dll")]

private static extern IntPtr RIL_GetCellTowerInfo(IntPtr hRil);

/* Definition from: http://msdn2.microsoft.com/en-us/library/aa919624.aspx */

[DllImport("ril.dll")]

private static extern IntPtr RIL_Deinitialize(IntPtr hRil);

}

}

----------------------

Additionally I have found the following code:

http://maps.alphadex.de/datafiles/fct0e1b11782832f02.cs

and also this

If you can read SIM, there is a EFLOCI record that contains current PLMN (MCC/MNC combination).

EFLOCI record ID is 0x6f7E.

LOCI record is 11 bytes in size and looks like this:

3b a7 81 03 64 f6 29 0b 55 00 00

The bit order is reverse. In this example bytes 4 and 5 give you 466 and bytes 5 and 6 give f92 ( f is ignored) resulting in MCC = 466 (Taiwan) and MNC = 92 (Vibo).

Another example:

b0 25 0b 37 32 f4 51 00 4e ff 00

234/15 is UK/Vodafone

To read SIM use SimInitialize/SimGetRecordInfo/SimReadRecord. On some phones it might require privileged certificate. It will likely require privileged certificate in the future versions of Windows Mobile

EDIT: Ups, I have seen that you already knows this.

----------------------

I am more familiar with VB, but I will give it a try.

How can I get the code ? As you I am very busy in my job, but i will see what I can do.

Have you checked with FieldTest the MCC and MNC code of your area ? Are they correct.

And again, I missed to send you via paypal a donation - I will do this today.

Regards

kuzco