• MFC获得当前用户等信息


    MFC获得当前用户等信息

    #ifndef UNICODE

    #define UNICODE

    #endif

    #pragma comment(lib, "netapi32.lib")

    #include <stdio.h>

    #include <windows.h>

    #include <lm.h>

    int wmain(int argc, wchar_t *argv[])

    {

    DWORD dwLevel = 102;

    LPWKSTA_INFO_102 pBuf = NULL;

    NET_API_STATUS nStatus;

    LPWSTR pszServerName = NULL;

    //

    // Check command line arguments.

    //

    if (argc > 2)

    {

    fwprintf(stderr, L"Usage: %s [\\ServerName] ", argv[0]);

    exit(1);

    }

    // The server is not the default local computer.

    //

    if (argc == 2)

    pszServerName = argv[1];

    //

    // Call the NetWkstaGetInfo function, specifying level 102.

    //

    nStatus = NetWkstaGetInfo(pszServerName,

    dwLevel,

    (LPBYTE *)&pBuf);

    //

    // If the call is successful,

    // print the workstation data.

    //

    if (nStatus == NERR_Success)

    {

    printf(" Platform: %d ", pBuf->wki102_platform_id);

    wprintf(L" Name: %s ", pBuf->wki102_computername);

    printf(" Version: %d.%d ", pBuf->wki102_ver_major,

    pBuf->wki102_ver_minor);

    wprintf(L" Domain: %s ", pBuf->wki102_langroup);

    wprintf(L" Lan Root: %s ", pBuf->wki102_lanroot);

    wprintf(L" # Logged On Users: %d ", pBuf->wki102_logged_on_users);

    }

    //

    // Otherwise, indicate the system error.

    //

    else

    fprintf(stderr, "A system error has occurred: %d ", nStatus);

    //

    // Free the allocated memory.

    //

    if (pBuf != NULL)

    NetApiBufferFree(pBuf);

    return 0;

    }

    来自: https://msdn.microsoft.com/en-us/library/windows/desktop/aa370663(v=vs.85).aspx

  • 相关阅读:
    HDU 1856 More is better
    并查集模板
    HDU 1325 Is It A Tree?
    HDU 1272 小希的迷宫
    CodeVS 2639 约会计划
    POJ 1163 数字三角形
    HDU 1232 畅通工程
    HDU 1213 How Many Tables
    树形结构打印二叉树
    网址收藏
  • 原文地址:https://www.cnblogs.com/time-is-life/p/6364033.html
Copyright © 2020-2023  润新知