Recent

Author Topic: System identification or CPU serial  (Read 8692 times)

gamagros

  • Newbie
  • Posts: 2
System identification or CPU serial
« on: March 30, 2011, 07:58:21 am »
I'm new in the forum and a newbie with Lazarus.

I have to migrate a FP+Lazarus application from Windows to Mac and need a method to identificate the system the app has been installed in. The windows version uses some properties of the system accessing to windows specific methods, but I don't know about similar methods to get any system parameter I can use to identificate and differentiate instances of the installed app.

Any help will be welcome.

G.

Blaazen

  • Hero Member
  • *****
  • Posts: 2920
  • POKE 54296,15
    • Eye-Candy Controls
Re: System identification or CPU serial
« Reply #1 on: March 30, 2011, 11:01:17 am »
Welcome.

There are compiler directives like:
Code: [Select]
{$ifdef window ... your Windows code ... {$endif}}
{$ifdef unix ... your Linux & Mac code ... {$endif}}
{$ifdef darwin ... your Mac code ... {$endif}}
where you can specify that different code will be compiled for different platforms.

Some code works for all platforms:
Code: [Select]
screen.width;
See: http://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide
Lazarus 2.1.0 r63881 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

gamagros

  • Newbie
  • Posts: 2
Re: System identification or CPU serial
« Reply #2 on: March 30, 2011, 11:13:24 am »
There are compiler directives like:

Thank you very much. I know I have directives and tools to know the kinda system the app is being compiled for or running on. Nevertheless, I don't want to know that but the identification of the machine. I want to tell a installation from  another. So, the serial number of the current computer where app is running or something similar would be perfect if I can get that info.

G.

rajivsoft

  • New Member
  • *
  • Posts: 48
Re: System identification or CPU serial
« Reply #3 on: April 05, 2011, 10:35:48 am »
with a bot of research i'v found this command that may help you:
Code: [Select]
sysctlwith -A you see all variables (they are MUCH, with -X MUCH MORE XD ), i'v found some interessant:
Code: [Select]
hw.cpufamily
machdep.cpu.feature_bits
machdep.cpu.extfeature_bits
machdep.cpu.signature
you can combine them toghether and then make a hash

btw to get a single value use
Code: [Select]
sysctl hw.cpufamilylook here to see how to get them http://www.lazarus.freepascal.org/index.php/topic,12697.msg65555.html#msg65555

ik

  • Jr. Member
  • **
  • Posts: 88
  • ik
    • LINESIP
Re: System identification or CPU serial
« Reply #4 on: April 05, 2011, 11:52:42 am »
On Linux you can parse /proc/cpuinfo for all of the details you require per CPU, so if you have quad core you will see there 4 or 8 CPU. if there are 8, then 4 of them are hyperthread CPU (Virtual CPU by Intel).

You can see there all of the details each CPU can provide, including flags of what they can do (For example does they support 64 bit/long mode even though you are on 32 bit and many more).

rajivsoft

  • New Member
  • *
  • Posts: 48
Re: System identification or CPU serial
« Reply #5 on: April 05, 2011, 01:00:03 pm »
On Linux you can parse /proc/cpuinfo for all of the details you require per CPU, so if you have quad core you will see there 4 or 8 CPU. if there are 8, then 4 of them are hyperthread CPU (Virtual CPU by Intel).

You can see there all of the details each CPU can provide, including flags of what they can do (For example does they support 64 bit/long mode even though you are on 32 bit and many more).
on Mac i havn't found any /proc/cpuinfo only sysctl hw for general hardware info and sysctl machdep.cpu for more cpu related info

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8731
  • FPC developer.
Re: System identification or CPU serial
« Reply #6 on: April 05, 2011, 04:06:34 pm »
Note that Darwin and FreeBSD also have a unit sysctl to do this programmatically (without external program calls)

 

TinyPortal © 2005-2018