如何以编程方式查找计算机的域
How to find the computer's domain programatically
目前大多数系统都连接到一个域左右。我可以进行任何方法/系统调用来获取系统当前域(类似于 gethostname 的东西)。我主要在寻找一些便携式解决方案(win/Lin),但如果你能指导我如何在 Linux 中获取信息,这将非常有帮助。我正在尝试在 Linux 的C++程序中获取相同的内容,但尚未能够。
澄清一下,我知道我们可以轻松获得主机名。它是我正在寻找的"localhost@somedomain"的"某个域"部分。
有一个
getdomainname()
函数,它获取您计算机的DNS域名(不是工作组/Windows域),例如:
#include <iostream>
#include <unistd.h>
int main() {
char buffer[1024];
getdomainname(buffer, sizeof(buffer));
std::cout << buffer << std::endl;
}
相关文章:
- 正在查找文档以获得PS4平台的C++中的设备信息
- 在C++中查找文件
- 模板元程序查找相似的连续类型名称
- 在UNIX系统中使用DIR查找文件的字节大小
- 查找最接近的大于当前数字的数字的索引
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 查找后更改类变量
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 使用正则表达式regex_search在字符串中查找字符串
- 使用gcc从静态链接的文件中查找可选符号
- EvtExportLogneneneba API正在将远程计算机的事件日志保存到远程PC本身.如何将其保存到主机
- 在C++中查找范围的长度
- 算法问题:查找从堆栈中弹出的所有序列
- 在多 GPU 计算机中查找空闲 GPU
- 查找服务器计算机中的物理 CPU 插槽数
- 从计算机名称中查找计算机 IP 地址
- 如何以编程方式查找计算机的域
- 如何在ROS中查找计算机的当前日期
- C++套接字编程 - 查找客户端计算机 IP、TrueIP 和绑定端口
- 启动多个程序扫描计算机以查找恶意软件