当前位置: 首页>>代码示例>>Python>>正文


Python win32wnet.Netbios方法代码示例

本文整理汇总了Python中win32wnet.Netbios方法的典型用法代码示例。如果您正苦于以下问题:Python win32wnet.Netbios方法的具体用法?Python win32wnet.Netbios怎么用?Python win32wnet.Netbios使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32wnet的用法示例。


在下文中一共展示了win32wnet.Netbios方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testNetbios

# 需要导入模块: import win32wnet [as 别名]
# 或者: from win32wnet import Netbios [as 别名]
def testNetbios(self):
        # taken from the demo code in netbios.py
        ncb = win32wnet.NCB()
        ncb.Command = netbios.NCBENUM
        la_enum = netbios.LANA_ENUM()
        ncb.Buffer = la_enum
        rc = win32wnet.Netbios(ncb)
        self.failUnlessEqual(rc, 0)
        for i in range(la_enum.length):
            ncb.Reset()
            ncb.Command = netbios.NCBRESET
            ncb.Lana_num = netbios.byte_to_int(la_enum.lana[i])
            rc = Netbios(ncb)
            self.failUnlessEqual(rc, 0)
            ncb.Reset()
            ncb.Command = netbios.NCBASTAT
            ncb.Lana_num = byte_to_int(la_enum.lana[i])
            ncb.Callname = str2bytes("*               ") # ensure bytes on py2x and 3k
            adapter = netbios.ADAPTER_STATUS()
            ncb.Buffer = adapter
            Netbios(ncb)
            # expect 6 bytes in the mac address.
            self.failUnless(len(adapter.adapter_address), 6) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_win32wnet.py

示例2: _netbios_getnode

# 需要导入模块: import win32wnet [as 别名]
# 或者: from win32wnet import Netbios [as 别名]
def _netbios_getnode():
    """Get the hardware address on Windows using NetBIOS calls.
    See http://support.microsoft.com/kb/118623 for details."""
    import win32wnet, netbios
    ncb = netbios.NCB()
    ncb.Command = netbios.NCBENUM
    ncb.Buffer = adapters = netbios.LANA_ENUM()
    adapters._pack()
    if win32wnet.Netbios(ncb) != 0:
        return
    adapters._unpack()
    for i in range(adapters.length):
        ncb.Reset()
        ncb.Command = netbios.NCBRESET
        ncb.Lana_num = ord(adapters.lana[i])
        if win32wnet.Netbios(ncb) != 0:
            continue
        ncb.Reset()
        ncb.Command = netbios.NCBASTAT
        ncb.Lana_num = ord(adapters.lana[i])
        ncb.Callname = '*'.ljust(16)
        ncb.Buffer = status = netbios.ADAPTER_STATUS()
        if win32wnet.Netbios(ncb) != 0:
            continue
        status._unpack()
        bytes = map(ord, status.adapter_address)
        return ((bytes[0]<<40L) + (bytes[1]<<32L) + (bytes[2]<<24L) +
                (bytes[3]<<16L) + (bytes[4]<<8L) + bytes[5])

# Thanks to Thomas Heller for ctypes and for his help with its use here.

# If ctypes is available, use it to find system routines for UUID generation. 
开发者ID:glmcdona,项目名称:meddle,代码行数:34,代码来源:uuid.py

示例3: Netbios

# 需要导入模块: import win32wnet [as 别名]
# 或者: from win32wnet import Netbios [as 别名]
def Netbios(ncb):
    ob = ncb.Buffer
    is_ours = hasattr(ob, "_pack")
    if is_ours:
        ob._pack()
    try:
        return win32wnet.Netbios(ncb)
    finally:
        if is_ours:
            ob._unpack() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:netbios.py

示例4: _netbios_getnode

# 需要导入模块: import win32wnet [as 别名]
# 或者: from win32wnet import Netbios [as 别名]
def _netbios_getnode():
    """Get the hardware address on Windows using NetBIOS calls.
    See http://support.microsoft.com/kb/118623 for details."""
    import win32wnet, netbios
    ncb = netbios.NCB()
    ncb.Command = netbios.NCBENUM
    ncb.Buffer = adapters = netbios.LANA_ENUM()
    adapters._pack()
    if win32wnet.Netbios(ncb) != 0:
        return
    adapters._unpack()
    for i in range(adapters.length):
        ncb.Reset()
        ncb.Command = netbios.NCBRESET
        ncb.Lana_num = ord(adapters.lana[i])
        if win32wnet.Netbios(ncb) != 0:
            continue
        ncb.Reset()
        ncb.Command = netbios.NCBASTAT
        ncb.Lana_num = ord(adapters.lana[i])
        ncb.Callname = '*'.ljust(16)
        ncb.Buffer = status = netbios.ADAPTER_STATUS()
        if win32wnet.Netbios(ncb) != 0:
            continue
        status._unpack()
        bytes = status.adapter_address[:6]
        if len(bytes) != 6:
            continue
        return int.from_bytes(bytes, 'big')

# Thanks to Thomas Heller for ctypes and for his help with its use here.

# If ctypes is available, use it to find system routines for UUID generation.
# XXX This makes the module non-thread-safe! 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:36,代码来源:uuid.py

示例5: _netbios_getnode

# 需要导入模块: import win32wnet [as 别名]
# 或者: from win32wnet import Netbios [as 别名]
def _netbios_getnode():
    """Get the hardware address on Windows using NetBIOS calls.
    See http://support.microsoft.com/kb/118623 for details."""
    import win32wnet, netbios
    first_local_mac = None
    ncb = netbios.NCB()
    ncb.Command = netbios.NCBENUM
    ncb.Buffer = adapters = netbios.LANA_ENUM()
    adapters._pack()
    if win32wnet.Netbios(ncb) != 0:
        return None
    adapters._unpack()
    for i in range(adapters.length):
        ncb.Reset()
        ncb.Command = netbios.NCBRESET
        ncb.Lana_num = ord(adapters.lana[i])
        if win32wnet.Netbios(ncb) != 0:
            continue
        ncb.Reset()
        ncb.Command = netbios.NCBASTAT
        ncb.Lana_num = ord(adapters.lana[i])
        ncb.Callname = '*'.ljust(16)
        ncb.Buffer = status = netbios.ADAPTER_STATUS()
        if win32wnet.Netbios(ncb) != 0:
            continue
        status._unpack()
        bytes = status.adapter_address[:6]
        if len(bytes) != 6:
            continue
        mac = int.from_bytes(bytes, 'big')
        if _is_universal(mac):
            return mac
        first_local_mac = first_local_mac or mac
    return first_local_mac or None 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:36,代码来源:uuid.py

示例6: _netbios_getnode

# 需要导入模块: import win32wnet [as 别名]
# 或者: from win32wnet import Netbios [as 别名]
def _netbios_getnode():
    """Get the hardware address on Windows using NetBIOS calls.
    See http://support.microsoft.com/kb/118623 for details."""
    import win32wnet, netbios
    ncb = netbios.NCB()
    ncb.Command = netbios.NCBENUM
    ncb.Buffer = adapters = netbios.LANA_ENUM()
    adapters._pack()
    if win32wnet.Netbios(ncb) != 0:
        return
    adapters._unpack()
    for i in range(adapters.length):
        ncb.Reset()
        ncb.Command = netbios.NCBRESET
        ncb.Lana_num = ord(adapters.lana[i])
        if win32wnet.Netbios(ncb) != 0:
            continue
        ncb.Reset()
        ncb.Command = netbios.NCBASTAT
        ncb.Lana_num = ord(adapters.lana[i])
        ncb.Callname = '*'.ljust(16)
        ncb.Buffer = status = netbios.ADAPTER_STATUS()
        if win32wnet.Netbios(ncb) != 0:
            continue
        status._unpack()
        bytes = status.adapter_address
        return ((bytes[0]<<40) + (bytes[1]<<32) + (bytes[2]<<24) +
                (bytes[3]<<16) + (bytes[4]<<8) + bytes[5])

# Thanks to Thomas Heller for ctypes and for his help with its use here.

# If ctypes is available, use it to find system routines for UUID generation.
# XXX This makes the module non-thread-safe! 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:35,代码来源:uuid.py

示例7: _netbios_macs

# 需要导入模块: import win32wnet [as 别名]
# 或者: from win32wnet import Netbios [as 别名]
def _netbios_macs():
        # get MAC addresses from NetBIOS.  See
        # <http://support.microsoft.com/kb/118623>.
        try:
            import netbios
            from win32wnet import Netbios

            ncb = netbios.NCB()
            ncb.Command = netbios.NCBENUM
            ncb.Buffer = a = netbios.LANA_ENUM()
            a._pack()
            if Netbios(ncb) == 0:
                a._unpack()
                for i in range(a.length):
                    ncb.Reset()
                    ncb.Command  = netbios.NCBRESET
                    ncb.Lana_num = _byte(a.lana[i])
                    if Netbios(ncb) == 0:
                        ncb.Reset()
                        ncb.Command  = netbios.NCBASTAT
                        ncb.Lana_num = _byte(a.lana[i])
                        ncb.Callname = '*'.ljust(16)
                        ncb.Buffer = s = netbios.ADAPTER_STATUS()
                        if Netbios(ncb) == 0:
                            s._unpack()
                            yield isMAC(_bytes2int(s.adapter_address[:6]))
        except (ImportError, AttributeError):
            pass 
开发者ID:ActiveState,项目名称:code,代码行数:30,代码来源:recipe-577191.py


注:本文中的win32wnet.Netbios方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。