3

I have an application that requires to control mobile broadband API.

I am struggling on correctly installing the api on my devices.

I've been follow the instructions in this document:

http://www.google.be/url?sa=t&rct=j&q=&esrc=s&frm=1&source=web&cd=1&cad=rja&ved=0CC0QFjAA&url=http%3A%2F%2Fdownload.microsoft.com%2Fdownload%2F7%2FE%2F7%2F7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2%2FMB_ManagedCode.docx&ei=kyvmUs7jE4e60QWbooHYDg&usg=AFQjCNG6yaGf4sRhdbWI99fE7tmQX8cmnA&sig2=2Fg-_DRYBIselKR19wTq2Q

and trying to combine the steps with this stackoverflow explanation

C# Read Windows Mobile Broadband connection properties

I have been able to lay a reference from visual studio to mbnapi.tlb in V7.0/lib. and I automatically now have a interop.mbnapi.tlb in my obj/debug folder.

When trying to "check the SIM is inserted and working / activated". => my code crashes on the following line

IMbnInterface[] mobileInterfaces = mbnInfMgrInterface.GetInterfaces() as IMbnInterface[];

When I run it on windows 8, mbnInfMgrInterface == null

I have already tried to install the same SDK on windows 8 as stated in the requirements of the document but the SDK is only meant for windows 7...

I have tried to register the mbnapi in windows 8 by performing

Regtlibv12 Mbnapi.tlb

no luck whatsoever...

what do I need to do to get this to work please?

anyone has some experience in this?

EDIT. on windows 7 (my development machine), I get the message "Device not ready", I think this is normal because I don't have mobile broadband on it, on windows 8 I do, but there the mobile interface manager is null => mbnInfMgrInterface == null.

thank you,

Community
  • 1
  • 1
user1841243
  • 1,663
  • 2
  • 19
  • 35
  • I'm in the same boat. You'd think someone would have done this before, right? I had great success with querying information from the Windows 8 API on the state of the interface using Windows.Networking.Connectivity. It is the telling it to connect when the interface is down I'm having issues with. This shows you how to access the Win8 API [link](http://blogs.msdn.com/b/cdndevs/archive/2013/10/02/using-windows-8-winrt-apis-in-net-desktop-applications.aspx) – Josh Dean Feb 18 '14 at 23:58
  • I've found that on my windows 8 tablet I can access the inbuilt mobile broadband, but on my desktop I cannot access an external dongle. Are you using internal or external modem? – Josh Dean Feb 19 '14 at 00:47
  • Hi, I was able to get it to work as well. I had overlooked a piece of code that I was copying from this thread: http://stackoverflow.com/questions/18577510/c-sharp-read-windows-mobile-broadband-connection-properties But I haven't tried with an external dongle, but since this thing works via interop, I'm glad our hardware or all our devices is the same.... – user1841243 Feb 19 '14 at 10:09
  • dell latitude 10 here – user1841243 Feb 20 '14 at 09:46

1 Answers1

0

Not sure exactly what you are after, but after struggling with IMbnInterface and GetSignalStrength() (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd323166(v=vs.85).aspx) and being unsuccessful, I found that you can obtain a lot of info using WMI:

        int maxBandwidth = 0;
        string query = "SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface";
        ManagementObjectSearcher moSearch = new ManagementObjectSearcher(query);
        ManagementObjectCollection moCollection = moSearch.Get();
        foreach (ManagementObject mo in moCollection)
        {
            if (Convert.ToInt32(mo["CurrentBandwidth"]) > maxBandwidth)
            {
                // Instead of CurrentBandwidth you may want to use BytesReceivedPerSec
                maxBandwidth = Convert.ToInt32(mo["CurrentBandwidth"]);
            }
        }

Please see answer here: Determining the network connection link speed and here is the list of properties you can obtain: https://msdn.microsoft.com/en-us/library/aa394293(VS.85).aspx

UPDATE:

Please note that I can build and debug the above code (as part of a larger WPF application) from within Visual Studio 2015 on either Windows 7 or Windows 8.1, and I can deploy the same application onto Windows 7 where it runs successfully. For some reason when I deploy this application on Windows 8.1, I get an Invalid query message.

UPDATE 2:

Please note that I found you cannot get the network info in Windows 8.1 in the same way as you do in Windows 7, in that the System.Management namespace is not available on Windows 8.1. See https://code.msdn.microsoft.com/windowsapps/network-information-sample-63aaa201

        string connectionProfileInfo = string.Empty;
        ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();

        if (InternetConnectionProfile == null)
        {
            rootPage.NotifyUser("Not connected to Internet\n", NotifyType.StatusMessage);
        }
        else
        {
            connectionProfileInfo = GetConnectionProfile(InternetConnectionProfile);
            OutputText.Text = connectionProfileInfo;
            rootPage.NotifyUser("Success", NotifyType.StatusMessage);
        }

        // Which calls this function, that allows you to determine how strong the signal is and the associated bandwidth
        string GetConnectionProfile(ConnectionProfile connectionProfile)
        {
            // ...
                if (connectionProfile.GetSignalBars().HasValue)
                {
                    connectionProfileInfo += "====================\n";
                    connectionProfileInfo += "Signal Bars: " + connectionProfile.GetSignalBars() + "\n";
                }
            // ...
        } 
user8128167
  • 6,929
  • 6
  • 66
  • 79