Code Monkey home page Code Monkey logo

Comments (6)

dahall avatar dahall commented on July 24, 2024

See

public static extern bool GetVersionEx(ref OSVERSIONINFOEX lpVersionInfo);

from vanara.

emako avatar emako commented on July 24, 2024

It looks different from the API results of NtDll.
R2X3O7$0QXUF1X57AT~QSHS

from vanara.

emako avatar emako commented on July 24, 2024

image
NtDll.RtlGetVersion is OK.

public static class NtDll
{
    [SecurityCritical]
    [DllImport(Lib.NTdll, SetLastError = true, CharSet = CharSet.Unicode)]
    [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
    public static extern int RtlGetVersion(out OSVERSIONINFOEX versionInfo);
}
[StructLayout(LayoutKind.Sequential)]
public struct OSVERSIONINFOEX
{
    public int OSVersionInfoSize;
    public int MajorVersion;
    public int MinorVersion;
    public int BuildNumber;
    public int Revision;
    public int PlatformId;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
    public string CSDVersion;
    public ushort ServicePackMajor;
    public ushort ServicePackMinor;
    public short SuiteMask;
    public byte ProductType;
    public byte Reserved;
}

Could you reopen the issuse?

from vanara.

dahall avatar dahall commented on July 24, 2024

Both those methods (GetVersionEx and RtlGetVersion) are marked as obsolete in lieu of the functions in VersionHelpers.h. You can find the Varana equivalents at PInvoke/Kernel32/VersionHelpers.cs

from vanara.

dahall avatar dahall commented on July 24, 2024

To use GetVersionEx you have to set the size or use the Default field:

var ver = OSVERSIONINFOEX.Default;
if (!GetVersionEx(ref ver)) ...

from vanara.

emako avatar emako commented on July 24, 2024

Kernel32.OSVERSIONINFOEX.Default make Kernel32.GetVersionEx return true, but it seems that the value is not eq to NtDll.RtlGetVersion.

Kernel32.GetVersionEx
image

NtDll.RtlGetVersion
image

Addtional infos:

My TargetFramework like following and I don't use any app.manifest file.

<TargetFramework>net7.0-windows10.0.22621.0</TargetFramework> // in my exe csproj
<TargetFramework>net7.0-windows</TargetFramework> // in my lib csproj

from vanara.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.