- Home /
How to access .NET application from Unity via a Process?
Hi
I have made a .NET application that get CPU id.
I used the System.Management classes in .NET that isn't supported in Mono.
Now the CPU id is stored in a string variable in .NET application.
How can I access this variable from Unity via a Process?
Is it possible at all?
Hi, maybe you can convert some information Unity will give you through SystemInfo.processorType ( http://docs.unity3d.com/ScriptReference/SystemInfo.html ) to an equivalent of a CPU ID.
Answer by Bunny83 · Oct 30, 2014 at 12:02 PM
Either use named pipes which would be the fastest way or use Sockets to exchange information between two .NET processes. However in your case it would probably be simpler you write the information to a file and let Unity read that file.
Thanks for answers, yes the easiest way is to write information to a file and read it with unity. But I want to make a software lock for my unity build and I will change CPU id with an algorithm to have Unique serial number for each computer. For security reasons, if I write this serial in a file that is on hard disk, it is easy for hackers to read it and I search different way for doing it.
Well, decompiling a .NET application is also quite "easy" ;)
Also are you aware of the fact that the CPUid is not guaranteed to be unique?. You might have a look at this SO question.
Yes you are right. I must combine several hardware ids for generate serial. $$anonymous$$aybe I must use SystemInfo class, if i can reach an Unique code with it. what is your idea Bunny? Is it possible?
Answer by liortal · Oct 30, 2014 at 11:44 AM
There's no easy way to get the string in the memory space of one app from another app.
I would say it would be probably easier to find a better solution that have 2 different apps communicate with each other (e.g: use a native plugin that retrieves this value).
NOTE: this approach would not work on all platforms of course.
You can achieve this in many different ways (See this link for more information on Inter Process Communication).
The easiest way it would be to have the external app report the CPU id value to the console, and have the game execute that app and read its output.
The game would parse the output from your external process and read the value (multiple values can be reported that way, as long as both apps agree on a common structure of what is being output and how to read it).
Your answer
![](https://koobas.hobune.stream/wayback/20220613170319im_/https://answers.unity.com/themes/thub/images/avi.jpg)