How is the NetworkAdapter.NetworkAdapterID generated in UWP? [duplicate] - c#

This question already has answers here:
C# - Get mac address in Universal Apps
(3 answers)
Closed 3 years ago.
I wanted to use the MAC Address of the device as a unique identifier, but this isn't exposed in the UWP API. The closest thing I can find is:
hostname.IPInformation.NetworkAdapter.NetworkAdapterId;
It seems to be the same value (after app restart and PC restart) but I don't know if it's robustly persistent. The docs don't seem to say, does anyone know what this ID actually consists of? Is it safe to use this as a reliable means of device identification?
If not, can someone recommend something?
Many thanks,
Peter

How is the NetworkAdapter.NetworkAdapterID generated in UWP
Derive from this case,
No, the NetworkAdapterId value is a GUID and has nothing to do with the machine MAC address. You cannot get the MAC adress of the computer through WinRT APIs exposed for the Windows Store application type.

Related

Create new/Reuse an instance of an application (Windows, .NET, WPF) [duplicate]

This question already has answers here:
What is the correct way to create a single-instance WPF application?
(39 answers)
Closed 6 years ago.
I've been struggling with this for more than several hours and cannot think of a solution.
I have an application that can be started in this way:
TestApplication.exe ID={GUID} filename={filename}
If there is not an instance of the application with the same GUID, a new instance should be started with ID={GUID} and the specified file should be loaded in it.
If there is an instance of the application with the same GUID, the user should be asked if he wants to close the file he is working on and if he confirms it - then the new file specified should be opened in the running instance.
Any ideas how to implement this?
Use a Mutex. See the first answer of this question:
What is the correct way to create a single-instance application?
Any ideas how to implement this?
Yes. Question answered. You never ask us to show us our ideas.
Let's get real.
One way is by window title, but having the GUID there is seriously not optimal.
As such, read up on NAMED MUTEXES. You can use that one to identify a program already running.
Alternatively - and better given you must actually send a signal - named pipes. You can register a named pipe with the GUID. Fails: Already exists. THAT allows the new application to actually signal the old one and or send a shutdown command.

Windows phone 8 - Application getting event fired from incoming call [duplicate]

This question already has answers here:
Windows Phone 8 support to capture SMS or a incoming call?
(3 answers)
Closed 8 years ago.
After looking at those links:
control-information-on-call-windows-phone-8
call-history-for-windows-phone-8
it seems that there is no way to do drop a call or to get calls history from an application using Windows Phone.
I would need to get a notification when an incoming call is starting/ending on Windows Phone 8.
Is is possible to do that even if I am not an OEM? If yes, what is the API to use?
For security reasons microsoft do not want to allow the apps to get incomming calls info, call history or message data. so a straight no on that.
No.
Reason: Security and Privacy of customer.

Time based serial key generation for PC Software [duplicate]

This question already has answers here:
How can I create a product key for my C# application?
(14 answers)
Closed 9 years ago.
How can i generate serial key for the C# Desktop Application (Windows application) ?
E.g. Software expires after a month. (Trial version).
If user changes Machine time then hoe could it be possible to validate the software for the specified time ?
There are many ways you can generate serial keys for your application in C#. You will most likely have make some sort of trade off between the simplicity (ie. the length of the key, readability, etc), and the security of a particular system.
I would recommend Software Protector(http://softwareprotector.clizware.net/) and SKGL (https://skgl.codeplex.com/). Software Protector would give you a user interface where you can generate your keys and SKGL API would allow you to validate those inside your own application. If you like, you can also include the source code of SKGL API (currently available in C# and VB.NET). You can set a time limit from 0 to 999, 8 custom features, and machine locking.
Regarding the time changing issue, the only way I see is to look up the local time (for that time zone) online using time.windows.com and check if that is equal to the current time on the pc. Please check this article: https://skgl.codeplex.com/discussions/472444
Please note that I am developing both SKGL API and Software Protector, which means that my answer might have a slight tendency!

way in .NET/C# to easily know if laptop is plugged in? [duplicate]

This question already has answers here:
How to detect when laptop power cable has been disconnected?
(7 answers)
Closed 9 years ago.
I'd like to call an API to know if the laptop is plugged into the wall. If it is I want to defer some CPU intense processing in order to save battery
I'd also like to be informed when this status changes (meaning when the user plugs the charger back in I'd like to be alerted)
in Win32 I'd probally go this route - RegisterPowerSettingNotification
is there something like this in .NET/C#?
I believe you can check SystemInformation.PowerStatus to see if it's on battery or not.
Boolean isRunningOnBattery =
(System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus ==
PowerLineStatus.Offline);
Edit: In addition to the above, there's also a System.Windows.Forms.PowerStatus class. One of its methods is PowerLineStatus, which will equal PowerLineStatus.Online if it's on AC Power.

Programmatically enabling/disabling hardware device [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicates:
[.NET] How do I disable a system device?
Win32 API function to programatically enable/disable device
Is there a way, in C#, to programmatically disable and re-enable a device? I'm looking for essentially the same functionality that occurs when you go into device manager and right click on a device and disable or enable it. How can I do this in C#?
Take a look at net-how-do-i-disable-a-system-device.
According to this link: http://bytes.com/topic/c-sharp/answers/513855-can-i-use-wmi-c-disable-enable-device
You need to interface with CfgMgr32
(Win32 API) to do this.
My first thought was to look at WMI but it's not there.
DevCon, which comes with the Device Drive Toolkit, provides a CLI to do this.
http://msdn.microsoft.com/en-us/library/ff541193(VS.85).aspx

Categories