1 //此函数功能是输入工作部件的tag,返回工作部件的路径 2 static string path_name(tag_t path_tag) 3 { 4 char part_fspec[MAX_FSPEC_SIZE+1]=""; 5 //得到工作部件的路径 6 UF_PART_ask_part_name(path_tag,part_fspec); 7 //拆分字符串 8 string s1_buffer=part_fspec; 9 string path=s1_buffer.substr(0,s1_buffer.find_last_of("\"));// 注意此处应是"\"不能为""。 10 return path; 11 } 12 extern DllExport void ufsta( char *param, int *returnCode, int rlen ) 13 { 14 /* Initialize the API environment */ 15 if( UF_CALL(UF_initialize()) ) 16 { 17 /* Failed to initialize */ 18 return; 19 } 20 21 /* TODO: Add your application code here */ 22 23 UF_initialize(); 24 25 tag_t work_part_tag=UF_ASSEM_ask_work_part(); 26 string s1_buffer=path_name(work_part_tag); 27 string s2_buffer="\biao_zhu.jpg"; 28 string work_part_path=s1_buffer+s2_buffer; 29 30 char *filename; 31 //分配内存 32 filename=(char*)malloc(sizeof(char)*work_part_path.length()); 33 strcpy(filename,work_part_path.c_str()); 34 //截取屏幕图片 35 UF_DISP_create_image (filename,UF_DISP_JPEG,UF_DISP_WHITE); 36 //释放内存 37 free(filename); 38 39 UF_terminate(); 40 41 /* Terminate the API environment */ 42 UF_CALL(UF_terminate()); 43 }