On 11 May, 2006 at 12:29, Charles Yeomans <[EMAIL PROTECTED]> wrote:

On May 11, 2006, at 11:58 AM, Jonathan Johnson wrote:

On May 11, 2006, at 10:54 AM, Greg Gunston wrote:

Hello,

I am looking for a way of finding out what processor my app is
running on.
On PPC macs, there is no problem, it is the Intel mac that I was
wondering about. I have tried using the System.Gestalt call but
that always returns  a G4.
Apparently under emulation, an Intel Mac will always return a G4
as the processor.
Therefore, I am looking for a way to detect if my app is running
under Rosetta and then I know I am on an Intel mac.

Does anyone have any ideas?

Yes:

<http://lists.apple.com/archives/perfoptimization-dev/2006/Jan/
msg00009.html>

However, I don't think anyone has ported it to REALbasic. The
declares shouldn't be too tricky, though.

They aren't; here's a port.

Function IsRosetta() as Boolean
   Soft Declare Function sysctl Lib "System.framework" (p1 as Ptr, p2
as Integer, p3 as Ptr, ByRef p4 as Integer, p5 as Integer, p6 as
Integer) as Integer

   Const CTL_HW = 6
   Const HW_MODEL = 2
   Const Null  = 0

   dim mib as new MemoryBlock(8)
   mib.Long(0) = CTL_HW         
   mib.Long(4) = HW_MODEL

   dim model as new MemoryBlock(32)
   dim len as Integer = model.Size

   dim theResult as Integer = sysctl(mib, 2, model, len, Null, 0)
   Return (theResult = 0) and (len = 9 and StrComp(model, "PowerMac",
0) = 0)
End Function

Perhaps some of you could test this on your machines.

Charles Yeomans

Sorry Charles, tried it with this code in a push button:

  If IsRosetta then
    MsgBox "We're working under Rosetta!"
  else
    MsgBox "We're not working under Rosetta!"
  end

but it replies that "We're not working under Rosetta!". I've asked my sister to check it on her mac-mini (G4) and she reports to see it returns the same answer.
HTH

Cheers,
Robert
MBP 2.0 GHz Intel Core Duo, 1GB DDR2 SDRAM, 10.4.6
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to