如何从LAN网络中的另一台计算机获取日期和时间? [英] How to get date and time from another computer in LAN network ?

查看:117
本文介绍了如何从LAN网络中的另一台计算机获取日期和时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从LAN网络中的另一台PC获取日期和时间

plz帮助我

解决方案

您将需要系统。引用的管理程序集,以及相应的 Imports 语句。

  Dim  pc 作为 字符串 =   REMOTEPC 
Dim remotePath As 字符串 = 字符串 .Format( \\ {0} \root \CIMV2,pc)
Dim ms 作为 ManagementScope(remotePath)
ms.Connect()

Dim oq 作为 ObjectQuery( SELECT * FROM Win32_LocalTime

Dim mos As ManagementObjectSearcher(ms,oq)

对于 每个 obj 作为 ManagementObject mos。[获取]()
Console.WriteLine( {0} - {1} - {2} {3}:{4}:{5},obj( ),obj( ),obj( ),obj( 小时),obj ( 分钟),_
obj( 第二个))
下一步


I want to get the date and time from another PC in LAN network
plz help me

解决方案

You will need the System.Management assembly referenced, and the appropriate Imports statement.

Dim pc As String = "REMOTEPC"
Dim remotePath As String = String.Format("\\{0}\root\CIMV2", pc)
Dim ms As New ManagementScope(remotePath)
ms.Connect()

Dim oq As New ObjectQuery("SELECT * FROM Win32_LocalTime")

Dim mos As New ManagementObjectSearcher(ms, oq)

For Each obj As ManagementObject In mos.[Get]()
    Console.WriteLine("{0}-{1}-{2} {3}:{4}:{5}", obj("Year"), obj("Month"), obj("Day"), obj("Hour"), obj("Minute"), _
        obj("Second"))
Next


这篇关于如何从LAN网络中的另一台计算机获取日期和时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆