# Define Pocketpcv1 1 # Define Smartphonev1 2 # Define Pocketpcv2 3 # Define Smartphonev2 4 Int Mydevicetype () {tchar szplatform [max_string_buffer]; Int Idevicetype = 0 ; Osversioninfo osver; getversionex (& osver ); If (Osver. dwmajorversion = 3 ){ If (Systemparametersinfo (spi_getplatformtype, Sizeof (Szplatform), szplatform, 0 )! = 0 ){ If (Lstrcmp (szplatform, text ( "Pocketpc" ) = 0 ) Idevicetype = pocketpcv1; // Runs on Pocket PC 2000 and 2002 Else if (Lstrcmp (szplatform, text ( "Smartphone" ) = 0 ) Idevicetype = smartphonev1; // Runs on Smartphone 2002 } Else { If (Getlasterror () = error_access_denied) // (5) Idevicetype = smartphonev1; // Is a smartphone: // smartphone creates an Access Denied error on // systemparametersinfo () }} Else { If (Osver. dwmajorversion = 4 ){ If (Systemparametersinfo (spi_getplatformtype, Sizeof (Szplatform), szplatform, 0 )! = 0 ){ If (Lstrcmp (szplatform, text ( "Pocketpc" ) = 0 ) Idevicetype = pocketpcv2; // Runs on Pocket PC 2003 Else if (Lstrcmp (szplatform, text ( "Smartphone" ) = 0 ) Idevicetype = smartphonev2;// Runs on Smartphone 2003 } Else { If (Getlasterror () = error_access_denied) // (5) Idevicetype = smartphonev2; // Is a smartphone: // smartphone creates an Access Denied error on // systemparametersinfo () }}} Return Idevicetype ;}
On smartphone, calling "systemparametersinfo ()" may fail due to "Access Denied", depending on whether the smartphone is locked and applied.ProgramSigned certificate. This is because only such a platform fails to be called because of access denied, so you can also use it as a flag for smartphone.