How to get tablet's IMEI number? - c#

This is not WinRT application. It's standard WPF. The device behaves as normal Windows PC, has Windows 10 installed. It has 3G broadband modem and a SIM card slot.

Some more information would be helpful. For example the brand and connection type (usb/internal).
If I understood you correctly you are looking for a solution to programmatically (in wpf) collect information (imei) about connected modems (in general or only one specific?)
Depending on the device you have several options.
Option 1 WMI:
Depending if the manufacturer included the information you might be successful by an simple WMI query.
To verify this take a look at the Device Manager (start -> run -> devmgmt.msc)
Right Click on your Modem -> Properties
Now go the register "Details".
Scroll through the Properties and look for your IMEI (the property doesn't necessarily is named IMEI). If you find it there, you can use a WMI Query to get the information into your WPF program.
Example here: http://www.codeproject.com/Questions/448125/How-to-write-WMI-Query-to-find-USB-MODEMS-IN-Cshar
Option 2 AT Commands:
If you are able to communicate with the modem over serial connection you can use so called "AT-Commands" to get the IMEI.
Information about the AT Commands can be found here: http://www.developershome.com/sms/atCommandsIntro.asp

Related

Tapi3lib.ITAddress does not return all devices

In an effort to automate some phone calling processes and integrate TAPI3 with another application, I am using to following code that was found as a sample;
tapi = new TAPI3Lib.TAPIClass();
tapi.Initialize();
foreach (TAPI3Lib.ITAddress ad in (tapi.Addresses as TAPI3Lib.ITCollection))
cbLines.Items.Add(ad.AddressName);
This code fills the devices in a dropdown and the dropdown only contains one device and it only shows from my computer. I tried installing the PIMphony_6.8_bld3200_XX_Alcatel on other computers where i add the IP address of the PBX device and a phone number (ex: 106) but it does not even show in the list the one device that i can see on my computer. I whatsoever have no idea what and how i managed to be able to see the device on my computer when i run this code. Obviously i am missing something. The devices we are using are Alcatel and the phone can be controlled by this app only on my computer. (i can provide the zip file containing PIMphony_6.8_bld3200_XX_Alcatel if needed). So the ultimate goal is to be able to see telephone lines on all computers so we can control them from the computer.
What am i missing Tapi3 experts? is it a missing installation on the other pc's ? and why only my device shows up?
You need a 3rd party TAPI driver installed, it might be on a DVD with the PBXor on some support website, but some manufacturers charge extra for it. This PIMphony looks like a phone control tool but that does not guarantee it is using TAPI under the hood, it may be using some propitiatory protocol.
I don't know TAPI3 but if you use TAPI correctly you should see 3 to 4 standard windows builtin devices (like WAN miniports) even if you have no drivers installed.
You need a decent test tool to compare results with, I would recommend phone.exe, it is kind of the standard test tool in the TAPI business. But it's getting harder to find online these days, here is a link to a slighly extended variant that google got me quickly: https://helpdesk.estos.de/Knowledgebase/Article/View/82/3/howto-ephoneexe--tapi-test-tool

How to Know USB device "HID" and "PID"

Please advice me, is there any built in function to retrieve "PID" and "VID" when USB is hooked up to the system? If not, what is the best way to get USB "HID" and "PID"? I need these two to detect USB HID device.
Since your tag specifies C# I'm going to assume that you want to do this using Microsoft Windows.
Using Windows I find this information using Device Manager under Computer Management (right-click on My Computer and select Manage). Using View -> Devices by connection open up the PCI bus node and then all of the USB nodes until you find the device you are looking for. Below is an example from my PC showing three USB devices on Intel(R) 82801G (ICH7 Family) USB Universal Host Controller entries.
Then look at the properties of the device -> then details -> then select property hardware ids and you should get the VID and PID of the device.
Don't know about native .NET, I only used LibUsbDotNet so far, check the examples.
Usually you would install the .NET assembly from the sourcefourge page, add the assembly to your Visual Studio project (References/.NET) and follow the examples (LibUsbDotNet Example Code/Getting Startet Example). Details depend on your C#/.NET/Visual Studio versions.

Bluetooth send/receive text without pairing using C# on 2 Windows 7 Computers

I have read that pairing is a must before communicating anything over bluetooth, but I want to know,
Can I create an application which would read a text which is
broadcasted by another bluetooth App without being paired.
Because we can see the names of other bluetooth devices around a device. So can't we set our bluetooth radio to a state that it would read any bluetooth boradcasting text message.
Example: there is createInsecureRfcommSocketToServiceRecord() & listenUsingInsecureRfcommWithServiceRecord() in android but aren't there such in C# for windows?
Thanks
My Ultimate Goal :-)
is creating an application running on windows 7 PCs, which create instant Bluetooth network for peer to peer file transfer and chat
Scenario
There is a group of people, each has this app on each computer, one wants to share a file, (may be an eBook, PDF or anything) with the rest. He sets his network "net" ( or any other name) in his app configuration and others also put that same name on each app. Finally each user can see the list of other Bluetooth nodes around them in their apps display, configured to same network name "net". so each can send files to selected nodes in the same network.
Design
Each user only turns on the Bluetooth radio and then enters a desired Network name in then app
Each application on PCs will communicate iteratively to reachable Bluetooth devices, through temporarily created connections (without pairing or user involvement), check their network names and list discoverable PCs with similar network names
Then they will share these lists among each other, so one PC knows the computers in their same network even though they are not in range directly.
Send files from one computer to one or many computers through a path resolved by an algorithm, even send chat texts.
All of this is going to be achieved through simple temporarily Bluetooth connections established between each application time to time, which requires no pairing or authentication, other than the Network Name. ( Because I don't know how to create Piconets using C#, or how to create bluetooth routing protocols.
No other security is implemented.
Please let me know of any other better design or way. Thank you very much for reading the lengthy text. Also include any helpful code which can help me achieve the above.
I make tens of un-paired connections every day... I don't know where this rumour comes from. :-,)
As you note on Android the default was for an authenticated connection -- maybe that's where the rumour started from? Even there, as you note, there are ways to request a 'pairing-not-required' connection e.g. listenUsingInsecureRfcommWithServiceRecord.
So, on the Microsoft stack on Windows one uses Bluetooth (RFCOMM) through a socket (winsock). By default that connection does not require authentication (pairing), nor encryption -- in fact to request auth/enc one must set a socket options. Similarly with Widcomm, you specify when you create the connection what security level you want, and that can be 'None'. Similarly on Bluetopia, similarly on BlueZ on Linux.
So if you use my library 32feet.NET, just use BluetoothClient and BluetoothListener and do not set cli.Authenticate=true etc. :-)
Some code examples
What's your ultimate goal? I've just realised that you were asking about file-transfer in another question... :-)
Anyway for transferring text... On the server-side have code like shown at: http://32feet.codeplex.com/wikipage?title=Bluetooth%20Server-side and on the client like: http://32feet.codeplex.com/wikipage?title=General%20Bluetooth%20Data%20Connections Don't know if you know TextWriter/-Reader sublclasses on .NET, anyway on one side:
....
var wtr = new StreamWriter(peerStream);
wtr.WriteLine("hello");
wtr.Flush();
and on the other:
....
var wtr = new StreamReader(peerStream);
var line = wtr.ReadLine();
MessageBox.Show(line);
There's code in the BluetoothChat which pretty much does something like that.
Alan

Removing COM Ports in Windows programmatically (Setup API ? )

I'm looking for a way of programmatically removing virtual COM ports created by multiple bluetooth pairing processes. Ideally, I would like to map every new paired device ( only on at once) to the same virtual port. Can this be done via the windows setup api ?
Thanks,
dinsdale
I would look at the devcon source code in the windows DDK. I've attached the readme so you can see that it has source to do exactly what you want -- disable a serial port.
DevCon Sample
DEVCON
DevCon is a command-line tool that displays detailed information about devices, and lets you search for and manipulate devices from the command line. DevCon enables, disables, installs, configures, and removes devices on the local computer and displays detailed information about devices on local and remote computers. DevCon is included in the Windows DDK.
ABOUT THIS DOCUMENT
This document describes the DevCon source code, which is included in the Windows DDK in the /src/setup/devcon directory. It explains the DevCon design, and describes how to use the SetupAPI and device installation functions to enumerate devices and perform device operations in a console application.
For a complete description of DevCon features and instructions for using them, see the DevCon help file in the DDK documentation in Driver Development Tools/Tools for Testing Drivers/DevCon.
SCOPE
These instructions pertain to Windows XP and Windows Server 2003. DevCon was designed for use on Windows 2000, Windows XP, and Windows Server 2003. It will not work on Windows 95, Windows 98, or Windows ME.
HOW IT WORKS
Running "devcon help" will provide a list of commands along with short descriptions of what each command does. "devcon help " will give more detailed help on that command. The interpretation of each command is done via a dispatch table "DispatchTable" that is at the bottom of "cmds.cpp". Some of the commands make use of a generic device enumerator "EnumerateDevices". A few of these commands will work when given a remote target computer, and will also work if using the 32-bit devcon on Wow64. A description of some of the more interesting functions and the APIs they use follows:
cmdClasses
This command demonstrates the use of SetupDiBuildClassInfoListEx to enumerate all device class GUID's. The function SetupDiClassNameFromGuidEx and SetupDiGetClassDescriptionEx are used to obtain more information about each device class.
cmdListClass
This command demonstrates the use of SetupDiClassGuidsFromNameEx to enumerate one or more class GUID's that match the class name. This command also demonstrates the use of SetupDiGetClassDevsEx to list all the devices for each class GUID.
cmdFind cmdFindAll cmdStatus
A simple use of EnumerateDevices (explained below) to list devices and display different levels of information about each device. Note that all but cmdFindAll use DIGCF_PRESENT to only list information about devices that are currently present. The main functionality for these and related devices is done inside FindCallback.
cmdEnable cmdDisable cmdRestart
These commands show how to issue DIF_PROPERTYCHANGE to enable a device, disable a device, or restart a device. The main functionality for each of these commands is done inside ControlCallback.
These operations cannot be done on a remote machine or in the context of Wow64. CFGMGR32 API's should not be used as they skip class and co-installers.
cmdUpdate
This command shows how to use UpdateDriverForPlugAndPlayDevices to update the driver for all devices to a specific driver. Normally INSTALLFLAG_FORCE would not be specified allowing UpdateDriverForPlugAndPlayDevices to determine if there is a better match already known. It's specified in DevCon to allow DevCon to be used more effectively as a debugging/testing tool. This cannot be done on a remote machine or in the context of Wow64.
cmdInstall
A variation of cmdUpdate to install a driver when there is no associated hardware. It creates a new root-enumerated device instance and associates it with a made up hardware ID specified on the command line (which should correspond to a hardware ID in the INF). This cannot be done on a remote machine or in the context of Wow64.
cmdRemove
A command to remove devices. Plug & Play devices that are removed will reappear in response to cmdRescan. The main functionality of this command is in RemoveCallback that demonstrates the use of DIF_REMOVE. This cannot be done on a remote machine or in the context of Wow64. CFGMGR32 API's should not be used as they skip class and co-installers.
cmdRescan
This command shows the correct way to rescan for all Plug & Play devices that may have previously been removed, or that otherwise require a rescan to detect them.
cmdDPAdd
This command allows you to add a Driver Package to the machine. The main functionality of this command demonstrates the use of SetupCopyOEMInf. Adding a Driver Package to the machine doesn’t mean the drivers are installed on devices, it simply means the drivers are available automatically when a new device is plugged in or a existing device is updated.
cmdDPDelete
This command allows you to uninstall a Driver Package from the machine. The main functionality of this command demonstrates the use of SetupUninstallOEMInf. Removing a Driver Package from the machine does not uninstall the drivers associated with a device. If you want to accomplish both then use cmdRemove on all the devices using a given Driver Package and then cmdDPDelete to remove the Driver Package itself from the machine. This functionality is not available in Windows 2000 or earlier.
cmdDPEnum
This command allows you to enumerate all of the 3rd party Driver Packages currently installed on the machine and also shows you how to get some common properties from a Driver Package (Provider, Class description, DriverVer date and version).
cmdDPEnumLegacy
This command shows you how to enumerate 3rd party Driver Packages on Windows Server 2003 and earlier operating systems.
Reboot
This function shows how to correctly reboot the machine from a hardware install program. In particular it passes flags to ExitWindowsEx that cause the reboot to be associated with hardware installation. You should never reboot the machine unnecessarily.
EnumerateDevices
Demonstrates the use of SetupDiGetClassDevsEx to enumerate all devices or all present devices, either globally or limited to a specific setup class. Demonstrates the use of SetupDiCreateDeviceInfoListEx to create a blank list associated with a class or not (for most cases, a blank list need not be associated with a class). Demonstrates the use of SetupDiOpenDeviceInfo to add a device instance into a device info list. These last two API's are ideal to obtain a DeviceInfoData structure from a device instance and machine name when mixing CFGMGR32 API's with SETUPAPI API's. SetupDiGetDeviceInfoListDetail is called to obtain a remote machine handle that may be passed into CFGMGR32 API's. SetupDiEnumDeviceInfo is called to enumerate each and every device that is in the device info list (either explicitly added, or determined by the call to SetupDiGetClassDevsEx). The instance ID is obtained by calling CM_Get_Device_ID_Ex, using information in devInfo (obtained from SetupDiEnumerateDeviceInfo) and devInfoListDetail (obtained from SetupDiGetDeviceInfoListDetail). GetHwIds is called to obtain a list of hardware and compatible ID's (explained below). Once an interesting device has been determined (typically by checking hardware ID's) then the callback is called to operate on that individual device.
GetHwIds
Shows how to get the complete list of hardware ID's or compatible ID's for a device using SetupDiGetDeviceRegistryProperty.
GetDeviceDescription
Shows how to obtain descriptive information about a device. The friendly name is used if it exists, otherwise the device description is used.
DumpDeviceWithInfo
Shows how to obtain an instance ID (or use any CFGMGR32 API) given HDEVINFO (device info list) and PSP_DEVINFO_DATA (device info data).
DumpDeviceStatus
Shows how to interpret the information returned by CM_Get_DevNode_Status_Ex. Refer to cfg.h for information returned by this API.
DumpDeviceResources
Shows how to obtain information about resources used by a device.
DumpDeviceDriverFiles
Provided as a debugging aid, obtains information about the files apparently being used for a device. It uses SetupDiBuildDriverInfoList to obtain information about the driver being used for the specified device. The driver list associated with a device may be enumerated by calling SetupDiEnumDriverInfo. In this case, there will be no more than one driver listed. This function proceeds to obtain a list of files that would normally be copied for this driver using DIF_INSTALLDEVICEFILES. SetupScanFileQueue is used to enumerate the file queue to display the list of files that are associated with the driver.
DumpDeviceDriverNodes
Provided as a debugging aid, this function determines the list of compatible drivers for a device. It uses SetupDiBuildDriverInfoList to obtain the list of compatible drivers. In this case, all drivers are enumerated, however typically DIF_SELECTBESTCOMPATDRV and SetupDiGetSelectedDriver would be used together to find which driver the OS would consider to be the best.
DumpDeviceStack
This function determines class and device upper and lower filters.
BUILDING THE DEVCON SAMPLE
To build the devcon sample:
Click the Build Environment icon of choice in the Development Kits Build Environments sub-menu. This will set up the correct build environment to build this sample. Note that this sample will build in the 64-bit environments as well as the 32-bit environments.
In a command window, change to the directory containing the DevCon source code. For example:
cd src\setup\devcon
Use the macro BLD or run the following from the command prompt:
build –c
This invokes the Microsoft make routines that produce the Build.log, Build.wrn, and Build.err log files.
When the build completes, the executable will be placed in the ObjXXX\I386 subdirectory of the directory specified in the Sources file (depending on build environment chosen).
If the build does not succeed, check for these errors: 1) the build environment is not set up properly, or 2) modifications made to the sample source code introduced errors.
USING DEVCON
DevCon is provided in ready-to-run form in tools\devcon. For usage, refer to the document provided with devcon.exe. DevCon is a command line utility with built-in documentation available by typing "devcon help".
TESTING
Type "devcon find *" to list device instances of all present devices on the local machine.
Type "devcon status #root\rdp_mou\0000" to list status of the terminal server mouse driver.
Type "devcon status PNP05" to list status of all COM ports.

How to use computer's Bluetooth to send Wallpapers to any cellphone, in C#?

I'd like to know if it is possible how to do it, because my client asked me if the program I'm developing could also send wallpapers to nearby cellphones(my program will be in a place with many people passing by, so it would be good to have the bluetooth feature).
Thanks!
it can send pictures as files, users then may set them as wallpapers.
Unless the phone and the computer support bluetooth and are connected, you cannot. You can send the files to mobiles over bluetooth. 32feet provides a nice library to perform bluetooh related operations. Try that.
Hope it helps.
To do this you would need to
Make sure each user's device is paired to your bluetooth "sever"
Create the ability to auto connect and send the file.
On your phone's application, receive the image file and set the phone background - this will be different for each type of phone's OS. I would assume you are aiming towards Window Mobile Devices, since you are using c#.
The first step i see as being the difficult step as each phone much "register" the bluetooth of the server to be paired with it.

Categories

Resources