为什么我在此代码中有一个EntryPointNotFoundException。 (来源pinvoke.net)我的操作系统是Windows XP SP3。
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace System_Info
{
class Program
{
[DllImport("kernel32.dll", SetLastError = false)]
static extern bool GetProductInfo(
int dwOSMajorVersion,
int dwOSMinorVersion,
int dwSpMajorVersion,
int dwSpMinorVersion,
out int pdwReturnedProductType);
static void Main(string[] args)
{
int ProductNum;
GetProductInfo(
Environment.OSVersion.Version.Major,
Environment.OSVersion.Version.Minor,
0,
0,
out ProductNum);
Console.WriteLine(Environment.OSVersion.Version.Build);
Console.WriteLine(Environment.OSVersion.Version.Major);
Console.WriteLine(Environment.OSVersion.Version.MajorRevision);
Console.WriteLine(Environment.OSVersion.Version.Minor);
Console.WriteLine(Environment.OSVersion.Version.MinorRevision);
Console.WriteLine(Environment.OSVersion.Version.Revision);
Console.WriteLine(ProductNum);
Console.ReadKey();
}
}
}
此致
弗洛里安
答案 0 :(得分:4)
根据this,它仅支持Vista或Windows Server 2008.(请参阅要求部分)
答案 1 :(得分:2)
好像你应该这样做:
OperatingSystem os = Environment.OSVersion;
Version osVer = os.Version;
Console.WriteLine(osVer.Build);
Console.WriteLine(osVer.Major);
Console.WriteLine(osVer.MajorRevision);
Console.WriteLine(osVer.Minor);
Console.WriteLine(osVer.MinorRevision);
Console.WriteLine(osVer.Revision);
如果它是您要查找的信息(而不是测试pInvoke)。