|
参考阿飞的C++多线程批量导出pdf,为什么,会出现如下错误啊
错误:
====================================================
'D:\2\NXBINNXOpenCPP_Wizard5.exe' 不是内部或外部命令,也不是可运行的程序
这个也没有空格啊,其实就是两个exe,但出现了以上错误
//主程序
extern "C" DllExport int ufusr_ask_unload()
{
// Unloads the image when the application completes
return (int)Session::LibraryUnloadOptionImmediately;
}
DWORD WINAPI ThreadProc1(LPVOID lpParameter)
{
printf("线程1开始\n");
int* p = (int*)lpParameter;//传入参数转换
for (int i = 0; i < 10; i++)
{
printf(".\n");
char msg[256];
sprintf_s(msg, "D:\\2\\NXBINNXOpenCPP_Wizard5.exe %d", *p);
system(msg);
(*p)++;
}
printf("线程1结束\n");
return 0;
}
DWORD WINAPI ThreadProc2(LPVOID lpParameter)
{
printf("线程2开始\n");
int* p = (int*)lpParameter;//传入参数转换
for (int i = 0; i < 10; i++)
{
printf(".\n");
char msg[256];
sprintf_s(msg, "D:\\2\\NXOpenCPP_Wizard5.exe %d", *p + 10);
system(msg);
(*p)++;
}
printf("线程2结束\n");
return 0;
}
void main()
{
int a = 0;//传入线程函数的参数,不需传递参数时为NULL
int b = 0;
//创建线程1
DWORD lpThreadId1 = 0;//传出参数,用于获得线程ID,如果为NULL则不返回
HANDLE hThread1 = CreateThread(NULL, 0, ThreadProc1, &a, 0, &lpThreadId1);
//WaitForSingleObject(hThread1, INFINITE);//等待单个对象
//创建线程2
DWORD lpThreadId2 = 0;
HANDLE hThread2 = CreateThread(NULL, 0, ThreadProc2, &b, 0, &lpThreadId2);
getchar();
}
//封装exe
extern void main(char argc, char* argv[])
{
/* Initialize the API environment */
UF_initialize();
/* TODO: Add your application code here */
//调exe传入参数
LPWSTR* szArglist = NULL;
int nArgs = 0;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
if (nArgs > 1)
{
CString str1 = szArglist[1];
//打开prt
tag_t PartTag = NULL_TAG;
UF_PART_load_status_t ErrorStatus;
UF_PART_open("D:\\_asm1_dwg1.prt", &PartTag, &ErrorStatus);
NXOpen::Session* theSession = NXOpen::Session::GetSession();
NXOpen::Part* workPart(theSession->Parts()->Work());
NXOpen::Part* displayPart(theSession->Parts()->Display());
NXOpen::PrintPDFBuilder* printPDFBuilder1;
printPDFBuilder1 = workPart->PlotManager()->CreatePrintPdfbuilder();
printPDFBuilder1->SetScale(1.0);
printPDFBuilder1->SetSize(NXOpen::PrintPDFBuilder::SizeOptionScaleFactor);
printPDFBuilder1->SetUnits(NXOpen::PrintPDFBuilder::UnitsOptionEnglish);
printPDFBuilder1->SetXDimension(8.5);
printPDFBuilder1->SetYDimension(11.0);
printPDFBuilder1->SetOutputText(NXOpen::PrintPDFBuilder::OutputTextOptionPolylines);
printPDFBuilder1->SetRasterImages(true);
printPDFBuilder1->SetWatermark("");
std::vector<NXOpen::NXObject*> sheets1(1);
NXOpen::Drawings::DrawingSheet* drawingSheet1(dynamic_cast<NXOpen::Drawings::DrawingSheet*>(workPart->DrawingSheets()->FindObject("Sheet 1")));
sheets1[0] = drawingSheet1;
printPDFBuilder1->SourceBuilder()->SetSheets(sheets1);
char msg[256];
sprintf_s(msg, "D:\\%s.pdf", (LPSTR)(LPCTSTR)str1);
printPDFBuilder1->SetFilename(msg);
NXOpen::NXObject* nXObject1;
nXObject1 = printPDFBuilder1->Commit();
printPDFBuilder1->Destroy();
//关闭prt
UF_PART_close(PartTag, 1, 1);
}
//取得参数后,释放CommandLineToArgvW申请的空间
LocalFree(szArglist);
/* Terminate the API environment */
UF_terminate();
}
|
|