我试过使用WMI,但到目前为止还没有成功。
Dim objLocator As New OLEObject("WbemScripting.SWbemLocator")
Dim objService As OLEObject
objService = objLocator.ConnectServer(".", "root\cimv2")
Dim instances As OLEObject
instances = objService.InstancesOf("Win32_ComputerSystem")无论我尝试做什么,下一步都会触发OLE异常。有没有其他已知的从REALbasic获得CPU计数的方法。我知道我可以从shell类中执行vbscript,但它对我来说太难看了。
发布于 2011-11-13 23:09:59
您可以调用GetSystemInfo函数并使用SYSTEM_INFO structure的dwNumberOfProcessors成员。
看一下下面的示例代码:
Declare Sub GetSystemInfo Lib "kernel32" Alias "GetSystemInfo" (lpSystemInfo As Ptr)
Dim SystemInfo as MemoryBlock=new MemoryBlock(36)
GetSystemInfo(SystemInfo)
Dim ProcessorCount as Integer=SystemInfo.Long(20)SYSTEM_INFO结构的大小为36字节。dwNumberOfProcessors之前的成员大小为20字节。
https://stackoverflow.com/questions/8112192
复制相似问题