Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 4 Jahren, 10 Monaten
Letzter Beitrag:
vor 4 Jahren, 10 Monaten
Beteiligte Autoren:
Peter Holemans, Cesar Flores

Find out current device

Startbeitrag von Cesar Flores am 10.09.2013 14:40

hi all

does any one knows if i could find out where is running my code?

i mean i want to detect if my code is running in an Ipad or if is running in an iphone.

i already know the functions InIosMode() or inAndroidMode() but i want to know if the device is an ipad or an iphone.

best regards


Hi Cesar,

Although I'm not aware of a basic function for that you could use SysXRes and SysYRes to get the screen resolution and determine based on that what iOs device it is...


Peter H.

As an add-on I found the below code on the French WindevMobile forum.
You can type XCode straight in the WM editor...
Code objectiv C pour détecter les infos du téléphone/tablettes


- (NSString *) platformString {
// Gets a string with the device model
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];

if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 2G";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
if ([platform isEqualToString:@"iPhone3,2"]) return @"iPhone 4";
if ([platform isEqualToString:@"iPhone3,3"]) return @"iPhone 4 (CDMA)";
if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";
if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5";
if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (GSM+CDMA)";

if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch (1 Gen)";
if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch (2 Gen)";
if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch (3 Gen)";
if ([platform isEqualToString:@"iPod4,1"]) return @"iPod Touch (4 Gen)";
if ([platform isEqualToString:@"iPod5,1"]) return @"iPod Touch (5 Gen)";

if ([platform isEqualToString:@"iPad1,1"]) return @"iPad";
if ([platform isEqualToString:@"iPad1,2"]) return @"iPad 3G";
if ([platform isEqualToString:@"iPad2,1"]) return @"iPad 2 (WiFi)";
if ([platform isEqualToString:@"iPad2,2"]) return @"iPad 2";
if ([platform isEqualToString:@"iPad2,3"]) return @"iPad 2 (CDMA)";
if ([platform isEqualToString:@"iPad2,4"]) return @"iPad 2";
if ([platform isEqualToString:@"iPad2,5"]) return @"iPad Mini (WiFi)";
if ([platform isEqualToString:@"iPad2,6"]) return @"iPad Mini";
if ([platform isEqualToString:@"iPad2,7"]) return @"iPad Mini (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,1"]) return @"iPad 3 (WiFi)";
if ([platform isEqualToString:@"iPad3,2"]) return @"iPad 3 (GSM+CDMA)";
if ([platform isEqualToString:@"iPad3,3"]) return @"iPad 3";
if ([platform isEqualToString:@"iPad3,4"]) return @"iPad 4 (WiFi)";
if ([platform isEqualToString:@"iPad3,5"]) return @"iPad 4";
if ([platform isEqualToString:@"iPad3,6"]) return @"iPad 4 (GSM+CDMA)";

if ([platform isEqualToString:@"i386"]) return @"Simulator";
if ([platform isEqualToString:@"x86_64"]) return @"Simulator";

return platform;

von Peter Holemans - am 10.09.2013 14:46
Hi Peter

Thank you for your answer.

i already found a solution, the problem was solved only determining the first window project, if in your plataform configuration you have included both (iphone/ipad) in the project explorer you have the ability to choose the first window of the project for iphone and the first window of the project for ipad.

referent to your code in ObjetiveC.

for run your code in a procedure what do i need to do? this is because i am curious about add objetiveC code in my applications.

best regards

von Cesar Flores - am 10.09.2013 15:35
Hi Cesar,

You open your procedure in the code editor, next click on 'WL' in the code bar and this will change to ObjC where you can write ObjectiveC code instead. If you click again it will change again to WL.

The same goes for browser side code in WebDev whichcan be changed to Javascript (JS) or WLanguage to Java in Java project...

I hope this helps you out!



von Peter Holemans - am 10.09.2013 15:55
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.