English 中文(简体)
单独确定使用NET/Mono的计算机?
原标题:Uniquely identifying a computer using .NET/Mono?

我需要一种独特的方法,使用计算机。 该网络在Windows和Libert同时运作。

这两个业务系统所使用的方法不一定相同。 也就是说:我可以采取莫诺的操作方式,操作在含水层上,并采用另一种做法。 NET在Windows上运行。

我对另一个网站(https://stackoverflow.com/questions/1308956/get-unique-system-identifiers-in-c)进行了考察。 NET正在使用世界海事委员会,但该工作将用莫诺机器进行,不管该顾问办公室是什么?

我对建议持开放态度。 提前感谢。

问题回答

我在获得我们C#/之一的中间点。 3. 用于第1737(2006)号决议工作的净应用 因此,我知道你正在做些什么,他们必须找到办法,来绕过含水层和Windows之间的分歧。

现在,这是非常不幸的,只是我为你们共同提出的粗略草案。 这样做可能更好,但也许会给你一个想法。

bool IsRunningMono()
{
    // With our application, it will be used on an embedded system, and we know that
    // Windows will never be running Mono, so you may have to adjust accordingly.
    return Type.GetType("Mono.Runtime") != null;
}

string GetCPUSerial()
{
    string serial = "";

    if(IsRunningMono())
    {
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = "lshw";
        startInfo.Arguments = "-xml";
        startInfo.UseShellExecute = false;
        startInfo.RedirectStandardOutput = true;

        using(Process p = Process.Start(startInfo))
        {
            p.WaitForExit();
            System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();

            xdoc.Load(new System.Xml.XmlTextReader(new StringReader(p.StandardOutput.ReadToEnd())));

            System.Xml.XmlNodeList nodes = xdoc.SelectNodes("node/node/node/serial");

            if (nodes.Count > 0)
            {
                serial = nodes[0].InnerText;              
            }
        }        
    }
    else
    {
       // process using wmi
    }

    return serial;
}

我试图将其装入数据Set,而不是XmlDocument,但每次都失败。 测试于Utu 9.10。 希望使你们走上正确的方向。

No, WMI will not work on Mono.

查阅 MAC Address work?





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签