简体   繁体   English

System.EntryPointNotFoundException和DllImport(“ kernel32.dll”)

[英]System.EntryPointNotFoundException and DllImport(“kernel32.dll”)

Why have I a EntryPointNotFoundException in this code. 为什么在此代码中出现EntryPointNotFoundException。 (source pinvoke.net ) My OS is Windows XP SP3. (源代码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();
        }
    }
}

Regards, 问候,

Florian 弗洛里安

根据这个 ,它仅支持Vista或Windows Server 2008中(参见要求部分)

Seems like you should do this: 似乎您应该这样做:

        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); 

if its the information you are looking for (as opposed to testing a pInvoke). 如果它是您要查找的信息(而不是测试pInvoke)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 kernel32.dll SetEnvironmentVariable中的EntryPointNotFoundException - EntryPointNotFoundException in kernel32.dll SetEnvironmentVariable 未处理的异常:DLL中的System.EntryPointNotFoundException - Unhandled Exception: System.EntryPointNotFoundException in DLL System.EntryPointNotFoundException: ''Gdi32.dll' DLL'sinde 'CreateRoundRecRgn' 未找到' - System.EntryPointNotFoundException: ''Gdi32.dll' DLL'sinde 'CreateRoundRecRgn' not found' C#EntryPointNotFoundException无法在DLL'kernel32.dll'中找到名为'SetDllDirectory'的入口点 - C# EntryPointNotFoundException Unable to find an entry point named 'SetDllDirectory' in DLL 'kernel32.dll' 从 DLL 调用 function 时出现 System.EntryPointNotFoundException - System.EntryPointNotFoundException when calling function from DLL kernel32.dll-GetPrivateProfileSectionNamesA - kernel32.dll - GetPrivateProfileSectionNamesA DllImport kernel32.dll 代码在控制台应用程序中工作但不在 UWP 中 - FindFirstFileW 返回 INVALID_HANDLE_VALUE - DllImport kernel32.dll code working in console app but not in UWP - FindFirstFileW returns INVALID_HANDLE_VALUE 在ubuntu中等效于kernel32.dll? - what is the equivalent of kernel32.dll in ubuntu? UWP的kernel32.dll中的SetThreadExecutionState类似物 - Analog of SetThreadExecutionState in kernel32.dll for UWP 在KERNEL32.dll中找不到FlsAlloc吗? - FlsAlloc cannot be found in KERNEL32.dll?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM