void OSInfo(){ DWORD dwLevel = 102; LPWKST..."/>
Win32 API功能封装
+ -

NetWkstaGetInfo获取系统版本信息

2024-02-18 13 0

NetWkstaGetInfo可用获取操作系统的基本信息:

#pragma comment(lib, "netapi32.lib")
#include <lm.h>
void OSInfo()
{
    DWORD dwLevel = 102;
    LPWKSTA_INFO_102 pBuf = NULL;
    NET_API_STATUS nStatus;
    LPWSTR pszServerName = NULL;

    nStatus = NetWkstaGetInfo(pszServerName,
        dwLevel,
        (LPBYTE*)&pBuf);
    //
    // If the call is successful,
    //  print the workstation data.
    //
    if (nStatus == NERR_Success)
    {
        printf("\n\tPlatform: %d\n", pBuf->wki102_platform_id);
        wprintf(L"\tName:     %s\n", pBuf->wki102_computername);
        printf("\tVersion:  %d.%d\n", pBuf->wki102_ver_major,
            pBuf->wki102_ver_minor);
        wprintf(L"\tDomain:   %s\n", pBuf->wki102_langroup);
        wprintf(L"\tLan Root: %s\n", pBuf->wki102_lanroot);
        wprintf(L"\t# Logged On Users: %d\n", pBuf->wki102_logged_on_users);
    }
    //
    // Otherwise, indicate the system error.
    //
    else
        fprintf(stderr, "A system error has occurred: %d\n", nStatus);
    //
    // Free the allocated memory.
    //
    if (pBuf != NULL)
        NetApiBufferFree(pBuf);
}

Windows10输出结果:

      Platform: 500
        Name:     DESKTOP-Q25N19N
        Version:  10.0
        Domain:   WORKGROUP
        Lan Root:
        # Logged On Users: 2

0 篇笔记 写笔记

NetWkstaGetInfo获取系统版本信息
NetWkstaGetInfo可用获取操作系统的基本信息:#pragma comment(lib, "netapi32.lib")#include void OSInfo(){ DWORD dwLevel = 102; LPWKST......
作者信息
我爱内核
Windows驱动开发,网站开发
好好学习,天天向上。
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!