loadrunner使用uuid

globals.h中添加如下代码:

char*lr_guid_gen(char*paramName){

typedefstruct_GUID{

unsignedlongData1;

unsignedshortData2;

unsignedshortData3;

unsignedcharData4[8];

}GUID;

GUID m_guid;

charbuf[50];

charpNameStr[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",// 大写

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);

returnlr_eval_string(pNameStr);

}



Action中添加如下代码:直接调用GUID就是uuid生成的变量
char*test;

charceshi[1024];

intmyFile;

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}"));


代码来自:https://www.cnblogs.com/qmfsun/还有另一种方法大家可以看这个博主的

你可能感兴趣的:(loadrunner使用uuid)