c# winform 화면에 ios, android 단말기 정보 표시하고 싶습니다.
안녕하세요.
지금 NET Framework 4.7.2 에서 c# 으로 ERP winform 을 만들고 있는데요..
ERP 프로그램을 띄운 후 PC 와 연결된 데이타 선에 안드로이드 폰이나 애플 폰을 꽂으면
단말기 정보 ( IMEI No, 모델명, 일련번호 등등.. ) 를 읽어와서 화면의 TEXT BOX 에 정보를 보여주고 싶은데요.
구글링을 해보니.. xamarin 를 사용하는 것만 나오는데..
winform 에서 스마트폰 단말기정보를 얻어오고 싶으면 어떤 부분을 검색해 보면 되는지
방향을 좀 알려주시면 감사하겠습니다.
윈폼에서 정보를 가져오는 자료는 많지 않은 것 같은데
WPF를 사용하는 경우에는 아래 샘플 소스가 있는 것 같습니다.
https://github.com/KaloyNayve/GetDeviceInfo
윈폼을 사용하는 경우 아래 라이브러리가 있기는 하나 이마저도 IMEI 같은 정보는 가져오지 못하는 것 같습니다.
https://forum.xda-developers.com/t/dev-androidlib-net-android-device-communication-and-management-library-01-20-13.1512685/
using iMobileDevice;
using iMobileDevice.DiagnosticsRelay;
using iMobileDevice.iDevice;
using iMobileDevice.Lockdown;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
namespace IphoneConsole
{
class Program
{
static void Main(string[] args)
{
NativeLibraries.Load();
ReadOnlyCollection<string> udids;
int count = 0;
var idevice = LibiMobileDevice.Instance.iDevice;
var lockdown = LibiMobileDevice.Instance.Lockdown;
var diagnostics = LibiMobileDevice.Instance.DiagnosticsRelay;
var ret = idevice.idevice_get_device_list(out udids, ref count);
if (ret == iDeviceError.NoDevice)
{
// Not actually an error in our case
Console.WriteLine("No devices found");
return;
}
ret.ThrowOnError();
// Get the device name
foreach (var udid in udids)
{
iDeviceHandle deviceHandle;
idevice.idevice_new(out deviceHandle, udid).ThrowOnError();
LockdownClientHandle lockdownHandle;
lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "Quamotion").ThrowOnError();
// 자신이 등록한 아이폰 이름
string deviceName;
lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();
Console.WriteLine($"이름: {deviceName}");
string serialNumber;
iMobileDevice.Plist.PlistHandle plistHandle;
lockdown.lockdownd_get_value(lockdownHandle, null, "SerialNumber", out plistHandle);
plistHandle.Api.Plist.plist_get_string_val(plistHandle, out serialNumber);
Console.WriteLine($"시리얼번호: {serialNumber}");
// 아이폰의 경우 Iphone OS 라고 나온다.
string productName;
lockdown.lockdownd_get_value(lockdownHandle, null, "ProductName", out plistHandle);
plistHandle.Api.Plist.plist_get_string_val(plistHandle, out productName);
Console.WriteLine($"상품명: {productName}");
// 내 아이폰의 경우 iPhone11,8 이라고 나오는데, 이 값을 가지고 일반적인 모델 이름을 얻으려면 Wiki 참조
string productType;
lockdown.lockdownd_get_value(lockdownHandle, null, "ProductType", out plistHandle);
plistHandle.Api.Plist.plist_get_string_val(plistHandle, out productType);
Console.WriteLine($"상품명: {productType}");
string modelNumber;
lockdown.lockdownd_get_value(lockdownHandle, null, "ModelNumber", out plistHandle);
plistHandle.Api.Plist.plist_get_string_val(plistHandle, out modelNumber);
Console.WriteLine($"모델번호: {modelNumber}");
string osVersion;
lockdown.lockdownd_get_value(lockdownHandle, null, "ProductVersion", out plistHandle);
plistHandle.Api.Plist.plist_get_string_val(plistHandle, out osVersion);
Console.WriteLine($"OS 버젼: {osVersion}");
string imei;
lockdown.lockdownd_get_value(lockdownHandle, null, "InternationalMobileEquipmentIdentity", out plistHandle);
plistHandle.Api.Plist.plist_get_string_val(plistHandle, out imei);
Console.WriteLine($"IMEI: {imei}");
string deviceColor;
lockdown.lockdownd_get_value(lockdownHandle, null, "DeviceColor", out plistHandle);
plistHandle.Api.Plist.plist_get_string_val(plistHandle, out deviceColor);
Console.WriteLine($"컬러: {deviceColor}");
string mobileSubscriberCountryCode;
lockdown.lockdownd_get_value(lockdownHandle, null, "MobileSubscriberCountryCode", out plistHandle);
plistHandle.Api.Plist.plist_get_string_val(plistHandle, out mobileSubscriberCountryCode);
Console.WriteLine($"통신사 국가 번호: {mobileSubscriberCountryCode}");
string mobilesubscriberNetworkCode;
lockdown.lockdownd_get_value(lockdownHandle, null, "MobileSubscriberNetworkCode", out plistHandle);
plistHandle.Api.Plist.plist_get_string_val(plistHandle, out mobilesubscriberNetworkCode);
Console.WriteLine($"통신사 네트워크 번호: {mobilesubscriberNetworkCode}");
lockdown.lockdownd_get_value(lockdownHandle, null, "CarrierBundleInfoArray", out plistHandle);
string str;
uint length = 0;
LibiMobileDevice.Instance.Plist.plist_to_xml(plistHandle, out str, ref length);
string carrier = "";
var xml = new XmlDocument();
xml.LoadXml(str);
var list = xml.GetElementsByTagName("key");
foreach(XmlNode xn in list)
{
if(xn.InnerText== "CFBundleIdentifier")
{
carrier = xn.NextSibling.InnerText;
break;
}
}
Console.WriteLine($"통신사: {carrier}");
DiagnosticsRelayClientHandle diagnosticsHandle;
diagnostics.diagnostics_relay_client_start_service(deviceHandle, out diagnosticsHandle, "PhoneConsole");
diagnostics.diagnostics_relay_request_diagnostics(diagnosticsHandle, "All", out plistHandle);
str ="";
length = 0;
LibiMobileDevice.Instance.Plist.plist_to_xml(plistHandle, out str, ref length);
string fullChargeCount = "";
xml = new XmlDocument();
xml.LoadXml(str);
list = xml.GetElementsByTagName("key");
foreach (XmlNode xn in list)
{
if (xn.InnerText == "CycleCount")
{
fullChargeCount = xn.NextSibling.InnerText;
break;
}
}
Console.WriteLine($"완충 횟수: {fullChargeCount}");
deviceHandle.Dispose();
lockdownHandle.Dispose();
}
}
}
}
=============================================
통신사는 심카드가 꽂혀 있어야 하며...
충전회수는 정확하지 않은 것 같습니다.