locked
First application (WM6) - stuck with Sim data access RRS feed

  • Question

  • Hello,

    I'm trying to write an application that (for starters) reads the information in the Sim card. I'm using WM6 professional SDK (and WM6 professional Emulator to execute the code) - I found an older existing example from web that uses Pocket PC 2003 Emulator where the Sim information is fetched through the Sim API function calls (I also started this example in this older emulator and it is working fine)...

    Now I've copied the example code to my own project (SmartPhone/Device Application/Windows Mobile 6 Professional SDK / .NET Compact Framework version 3.5) and I cannot get it to work anymore.

    The beginning of the code is simpy the following:

    int hSim = 0;
    uint phoneUsed = 0;
    uint phoneTotal = 0;

    uint h_res = (uint)SimWrap.SimInitialize(0, 0, 0, ref hSim);
    h_res = (uint)SimWrap.SimGetPhonebookStatus(hSim, SimWrap.SIM_PBSTORAGE_SIM, ref phoneUsed, ref phoneTotal);

    and in SimWrap class I have (among other things) following definitions:

    public const int SIM_PBSTORAGE_SIM = 0x10; // General SIM Storage

    [DllImport("cellcore.dll")]
    public static extern int SimInitialize(uint dwFlags, int lpfnCallBack, uint dwParam, ref int lphSim);

    [DllImport("cellcore.dll")]
    public static extern int SimGetPhonebookStatus(int hSim, uint dwLocation, ref uint lpdwUsed, ref uint lpdwTotal);

    I've printed out the results from initialize and getPhonebookstatus - and they are 0 & 2281701482 (0x8800006A), respectively. So initialize seems to be ok but for the getPhonebookStatus is failing - with failurecode SIM_E_RADIONOTPRESENT (?). I don't understand what this failurecode means in practice and I couldn't find an answer from forums - might be something trivial in some configuration/settings?, as I said I'm not yet that familiar with this development environment.

    Any help will be highly appreciated, br
    -Juha

    Monday, February 23, 2009 9:05 AM

Answers

  • Hi _Juha,

    I don't know where you got the code, please refer to the thread, which provide a sample, it works fine in my local.

    Accessing SIM using C# SIM Manager API


    Since SIM API are privileged API, please try to sign with a privileged cerficate.


    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Wednesday, February 25, 2009 3:25 AM
  • Hello, and thanks.

    I followed through the example you were referring in your example and set the certificate and tried to run the existing example - and ran into the same problem with the other example. This time the error indication itself was more informative (A wireless radio must be attached to use the phone) and this lead me to the answer that my emulator settings were not correct to begin with.

    http://social.msdn.microsoft.com/Forums/en-US/microsoftdeviceemu/thread/71afca08-f701-45a8-b488-3ea1fed9ffef/ had the instructions how to fix this particalar issue I was facing (matching the com ports).

    So again, thank you very much for your quick response - it helped me getting back on track. Now I'm off to explore more about the Sim handling =)

    best regards,
    -Juha
    Wednesday, February 25, 2009 1:11 PM

All replies

  • Hi _Juha,

    I don't know where you got the code, please refer to the thread, which provide a sample, it works fine in my local.

    Accessing SIM using C# SIM Manager API


    Since SIM API are privileged API, please try to sign with a privileged cerficate.


    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Wednesday, February 25, 2009 3:25 AM
  • Hello, and thanks.

    I followed through the example you were referring in your example and set the certificate and tried to run the existing example - and ran into the same problem with the other example. This time the error indication itself was more informative (A wireless radio must be attached to use the phone) and this lead me to the answer that my emulator settings were not correct to begin with.

    http://social.msdn.microsoft.com/Forums/en-US/microsoftdeviceemu/thread/71afca08-f701-45a8-b488-3ea1fed9ffef/ had the instructions how to fix this particalar issue I was facing (matching the com ports).

    So again, thank you very much for your quick response - it helped me getting back on track. Now I'm off to explore more about the Sim handling =)

    best regards,
    -Juha
    Wednesday, February 25, 2009 1:11 PM