8000 windows 系统获取系统主机域名 · Issue #225 · holdyounger/ScopeBlog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Ski 8000 p to content
windows 系统获取系统主机域名 #225
Open
@holdyounger

Description

@holdyounger

windows 系统获取系统主机域名

> 概述:windows操作系统下获取主机域名

// GetDominName.cpp : 获取主机域名
//

#include <Windows.h>
#include <DSRole.h>

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

#include <stdio.h>

int main(int argc, char ** argv)
{
	DSROLE_PRIMARY_DOMAIN_INFO_BASIC * info;
	DWORD dw;

	dw = DsRoleGetPrimaryDomainInformation(NULL,
		DsRolePrimaryDomainInfoBasic,
		(PBYTE *)&info);
	if (dw != ERROR_SUCCESS)
	{
		wprintf(L"DsRoleGetPrimaryDomainInformation: %u\n", dw);
		return dw;
	}

	if (info->DomainNameDns == NULL)
	{
		wprintf(L"DomainNameDns is NULL\n");
	}
	else
	{
		wprintf(L"DomainNameDns: %s\n", info->DomainNameDns);
	}

	system("pause");

	return 0;
}

输出示例:

image-20230814100602822

blog link windows 系统获取系统主机域名

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0