- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有办法通过 Windows API 来确定哪个是主要/默认网络适配器?
例如,如果我的 PC 有两个网卡,我需要知道系统使用哪个网卡上网,如果我有一个网络适配器和一个虚拟适配器,则类似。
我试过 GetAdaptersAddresses
但它没有显示哪个是最喜欢的,也许是 GetBestInterface
?
最佳答案
如何使用 GetAdaptersInfo并寻找满足您要求的 IP 范围?
或者,遇到这个 (WMI):
https://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx
~剪断:
Once you have done so, you will likely have reduced your list to one or two configured adapters.
You can also use the following procedure to find the default adapter:
- Run the following query: "SELECT InterfaceIndex, Destination FROM Win32_IP4RouteTable WHERE Destination='0.0.0.0'" You should only have one default network destination 0.0.0.0.
- Use the InterfaceIndex to retrieve the Network Adapter you want. "SELECT * FROM Win32_NetworkAdapter WHERE InterfaceIndex=" + insertVariableHere
这是一篇声称可以确定默认值的 CodeProject 文章:
http://www.codeproject.com/Articles/13421/Getting-the-Physical-MAC-address-of-a-Network-Inte
获取网络接口(interface)卡的物理 (MAC) 地址并确定它是否是多宿主系统上的主适配器
Finding out if the adapter with the given index is the primary adapter In order to find out if the adapter with the given index is the primary adapter, I had to add a function to the dialog class CNetCfgDlg. This code iterates over the m_pAdapters array, comparing the given adapter index with the index for each adapter in the array. If the given adapter index is equal to the smallest index of all adapters in the array, then it is the primary adapter
还有一件事需要考虑,每个适配器都有“自动度量”设置,它似乎选择最低设置作为首选(尽管不确定如何以编程方式访问此度量设置):
http://www.softminer.net/2011/09/setting-default-network-adapter-in.html
关于winapi - 如何通过WinApi判断默认网卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35879894/
判断置顶文章 is_sticky() 函数用来判断一篇文章是否为置顶文章。 用法 ?
判断结构要求程序员指定一个或多个要评估或测试的条件,以及条件为真时要执行的语句(必需的)和条件为假时要执行的语句(可选的)。 下面是大多数编程语言中典型的判断结构的一般形式: 判断语句 C
我经常这样写: (if (nil? a-value) another-value a-value) 是否有更简单的功能可用,例如: (if-nil? a-value another-value) 最佳
MySQL IF 语句允许您根据表达式的某个条件或值结果来执行一组 SQL 语句。 要在 MySQL 中形成一个表达式,可以结合文字,变量,运算符,甚至函数来组合。表达式可以返回 TRUE,FA
也就是说,是否有一种工具可以自动显示给定语法的完整语言,包括突出歧义(如果有)? 最佳答案 BNF 风格的文法可能有一些特殊性,但总的来说,确定给定的上下文无关文法(例如 BNF)是否有歧义是不可能的
有没有办法确定像下面这样的 Axios 请求是否收到了答案并完成了? axios.get('/api') .then(response => this.data = response.data); 最
我想请大家禁用 Firebug 。如何确定自己安装了firebug?所以它是一个跨浏览器,并在 Chrome、Mozilla 和 IE8 + 中确定 最佳答案 两步: 如果 window.consol
我有一个看起来像这样的对象: var searchFilter = {_id: XXX, approved: true} 用于驱动 Meteor 集合搜索过滤器。然后,我有一对文本框,允许用户输入一系
我正在循环并向我的数据库中插入几百万条记录。性能是第一要务。 我想利用无状态 session ,但您可能知道它们不支持在更复杂的实体上级联对象。 是否有一种通用方法可以确定实体是否具有级联记录?如果是
我正在使用 pdfminer 解析一些 PDF 文件。图书馆。 我需要知道文档是否是扫描文档,扫描机将扫描图像放在顶部,将 OCR 提取的文本放在背景中。 有没有办法识别文本是否可见,因为 OCR 机
我正在寻找一种方法来找出当前为浏览器游戏 TribalWars 编写的脚本打开的页面。 URL 的设置非常相似,对于知道自己在做什么的人来说这应该很容易(我显然不知道)。 URL 如下所示: http
我在 C# 中使用包装的 C 库,需要将图像从该库转换为位图并返回,但没有复制像素缓冲区。 转换为位图很简单: Bitmap WrapAsBitmap(CImage image) { retu
有没有办法检查调用方法的Controller是否来自Area内的Controller? 例如,我有一个继承自 AuthorizeAttribute 的类,例如 public class CustomA
是否可以找到MySQL View 中某列所属的表名? 如果 View 构造为 CREATE VIEW alpha_view AS SELECT alpha.col1, alpha.col2,
如何判断 .Net 应用程序是作为桌面应用程序运行还是作为服务运行? 我们正在尝试使用 Fitnesse 测试我们的应用程序,它将应用程序作为服务加载,然后调用它。但是当一个模式错误框被按下时,它就会
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求提供代码的问题必须表现出对所解决问题的最低限度理解。包括尝试过的解决方案、为什么它们不起作用,以及
我试图计算出 iframe 内容的大小,以便调整 iframe 元素的大小以包含其内容。 如何确定 iFrame 是否已加载以及我是否可以可靠地测量它的内容尺寸。 注意:onload 事件不会执行,因
这个问题在这里已经有了答案: How to write portable code in c++? (12 个答案) 关闭 9 年前。 我正在尝试编写可以用任何现代版本的 g++ 编译的代码,但遇到
这个问题在这里已经有了答案: distinguish shared objects from position independent executables (2 个答案) 关闭 4 年前。 我有
我的目标是如果 dte 与当前时间相差不到 1 小时,则停止循环。是否有“ ruby 方式”来做到这一点? #THIS IS AN INFINITE LOOP, DONT RUN THIS dte=D
我是一名优秀的程序员,十分优秀!