char* lr_guid_gen(char* paramName){ //生成GUID方法 typedef struct _GUID { unsigned long Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; } GUID; GUID m_guid; char buf[50]; char pNameStr[50]; CoCreateGuid(&m_guid); // 定义输出格式 //sprintf (buf, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", // 大写 // sprintf (buf, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",// 小写 sprintf (buf, "%08lX%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X",// 小写 m_guid.Data1, m_guid.Data2, m_guid.Data3, m_guid.Data4[0], m_guid.Data4[1], m_guid.Data4[2], m_guid.Data4[3], m_guid.Data4[4], m_guid.Data4[5], m_guid.Data4[6], m_guid.Data4[7]); lr_save_string(buf, paramName); sprintf(pNameStr,"{%s}",paramName); return lr_eval_string(pNameStr); } Action() { char *test; lr_load_dll("ole32.dll"); //引用windows生成GUID的API test=lr_guid_gen("GUID"); //调用上面lr_guid_gen()方法 lr_save_string(test,"GUID"); lr_output_message(test); lr_output_message("xxxxxxxxxxxxx:%s",lr_eval_string("{GUID}")); return 0; } |