Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS MacCF Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/CPU Type
This example is the version from Sun, 17th Mar 2012.
Project "CPU Type.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
EventHandler Sub Open()
Title="CPU: "+CPU.CPUKindString
End EventHandler
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Module CPU
Const intel = 6
Const ppcEmulator = 1
Const ppcG3 = 3
Const ppcG4 = 4
Const ppcG5 = 5
Protected Function CPUKind() As integer
if TargetLinux then
Return intel
elseif TargetWin32 then
Return intel
elseif TargetMacOS then
dim m as MemoryBlock
dim cputype, cpusubtype as integer
dim s as string
m=SystemControlByNameMBS("hw.cputype")
if m<>nil then
cputype=m.Long(0)
m=SystemControlByNameMBS("hw.cpusubtype")
if m<>nil then
cpusubtype=m.Long(0)
Select case cputype // only types for Mac OS X listed
case 7 // X86
Return intel // only when RB compiles for Intel!
case 18 // PowerPC
// Maybe emulator?
m=SystemControlByNameMBS("sysctl.proc_native")
if m=nil then // not found, so real PowerPC
Select case cpusubtype
case 9
Return ppcG3
case 10
Return ppcG4
case 11
Return ppcG4
case 100
Return ppcG5
end Select
else
Return ppcEmulator
end if
end Select
end if
end if
else
MsgBox "?"
end if
End Function
Protected Function CPUKindString() As String
Select case CPUKind
case intel
Return "Intel CPU"
case ppcEmulator
Return "PPC Emulator"
case ppcg3
Return "PPC G3"
case ppcg4
Return "PPC G4"
case ppcg5
Return "PPC G5"
else
Return "?"
end Select
End Function
End Module
End Project
See also:
The items on this page are in the following plugins: MBS MacCF Plugin.