cocos2dx下,包含头文件
std::string uid = "";
uuid_t uu;
int i;
uuid_generate(uu);
for (i = 0; i < 16; i ++) {
char aa[10]="";
sprintf(aa, "%02X",uu[i]);
uid+=aa;
}
return uid;<?php
function create_guid(){
$micortime = microtime();
list($a_dec,$a_sec) = explode(" ", $micortime);
$dec_hex = dechex($a_dec*1000000);
$sec_hex = dechex($a_sec);
ensure_length($dec_hex, 5);
ensure_length($sec_hex, 6);
$guid = "";
$guid.=$dec_hex;
$guid.=create_guid_section(3);
$guid.='-';
$guid.=create_guid_section(4);
$guid.='-';
$guid.=create_guid_section(4);
$guid.='-';
$guid.=create_guid_section(4);
$guid.='-';
$guid.=$sec_hex;
$guid.=create_guid_section(6);
return $guid;
}
function ensure_length(&$string,$length){
$strlen = strlen($string);
if ($strlen<$length) {
$string = str_pad($string, $length,"0");
}
elseif ($strlen>$length){
$string = substr($string, 0,$length);
}
}
function create_guid_section($characters){
$return = "";
for ($i = 0;$i < $characters;$i++){
$return.=dechex(mt_rand(0, 15));
}
return $return;
}
?>以上就介绍了获取唯一设备标识符,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号