搬家第58天-citect2018使用citectVBA获取系统盘符
如果需要获取当前计算机操作系统安装在什么盘符上,可以新建以下citectVBA函数:
Sub GetOSPath()
Dim objWMIService As Object
Dim colItems As Object
Dim objItem As Object
Dim strSystempath As string
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objItem In colItems
strSystempath =objItem.SystemDrive
Next
msgbox strSystempath
End Sub
调用这个citectVBA函数,就能得出操作系统安装的盘符。