Continue to Site

About function ProToolkitTaskExecute()?

LittleTome

New member
Does anybody know how to use function of ProToolkitTaskExecute()? The following is my code segmemt. I always got the reture value: PRO_TK_E_NOT_FOUND, and I don't know why.


ProToolkitDllHandledllhandle;
ProErrorerror,err;
ProPathpropath;
ProNameproname;
ProBooleanprobool=PRO_B_TRUE;

ProStringToWstring(proname,"hellodll");
err=ProToolkitDllLoad(proname,"E:\\hello\\Release\\hello.dll ",".\\text\\usermsg.txt",probool,&dllhandle,&error,p ropath);


ProArgument*arg;//ret
ProArgument*proarg;//input

ProArgumenttmp;


ProArrayAlloc(0,sizeof(ProArgument),1,(ProArray*)proar g);
ProStringToWstring(tmp.label,"IMPGEOMTYPE");
tmp.value.type=PRO_VALUE_TYPE_INT;
tmp.value.v.i=121;

ProArrayObjectAdd((ProArray*)proarg,-1,1,& nbsp;&tmp);
error=ProToolkitTaskExecute(dllhandle,"yyg",proarg,&arg, &err);
 
I am also getting the PRO_TK_E_NOT_FOUND error. Did you guys get your programs working? I do know that the function I am trying to call must have PRO_TK_DLL_EXPORT macro in front of it's definition, which I did. But no luck, it still doesn't work.
 
Have you guys over come this PRO_TK_E_NOT_FOUND error? I am also getting same error. Please give me update on the same.

Thanks,
 
Here is my final working code to load an external dll and call a function within it.


Code:
ProError TAPGenerator::ExecuteAutoPod() {


char *szFuncName = "ExecuteAutoPod()",


szTemp[128];


int nPid = 0;


ProError pro_error = PRO_TK_NO_ERROR,


pro_errorDll = PRO_TK_NO_ERROR;


ProPath pro_wszErrBuf;


ProCharPath pro_szErrBuf;


ProArgument *pro_aArgInput = NULL,


*pro_aArgOutput = NULL;


HKEY hSubKey;


DWORD keyType = REG_SZ,


nAppIdSize = 0;


ProName pro_wszAppId,


pro_wszAppName;


//Check if AutoPod is loaded


if(m_pro_bAutoPodLoaded == PRO_B_FALSE) {


ProUtilPrint("Autopod DLL has not been acquired.\n");


//Get xtop.exe pid


nPid = _getpid();


//Open the reg key


sprintf(szTemp, "%s\\%i", m_strApRegSubKey.c_str(), nPid);


if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, szTemp, 0, KEY_READ, &hSubKey) != ERROR_SUCCESS)


return PRO_TK_E_NOT_FOUND;


//Read the key value


nAppIdSize = sizeof(szTemp) - 1;


if(RegQueryValueEx(hSubKey, "AppID", NULL, &keyType, (BYTE*)szTemp, &nAppIdSize) != ERROR_SUCCESS)


return PRO_TK_E_NOT_FOUND;


//Close the key


RegCloseKey(hSubKey);


ProStringToWstring(pro_wszAppId, szTemp);


ProUtilPrint("Getting DLL handle with PID: %i AppID: %S\n", nPid, pro_wszAppId);


//Get a handle to the dll


pro_error = ProToolkitDllHandleGet(pro_wszAppId, &m_pro_hTkDllAutoPod);


PROUTIL_CALL_REPORT("ProToolkitDllHandleGet()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR && pro_error!=PRO_TK_E_NOT_FOUND);


if(pro_error == PRO_TK_E_NOT_FOUND) {


//Load the external AutoPod dll


swprintf(pro_wszAppName, L"%S", m_strApName.c_str());


pro_error = ProToolkitDllLoad(pro_wszAppName, (char*)m_strApExecFile.c_str(), (char*)m_strApTextDir.c_str(), PRO_B_TRUE, &m_pro_hTkDllAutoPod, &pro_errorDll, pro_wszErrBuf);


ProUtilCallReport("ProToolkitDllLoad()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);


if(pro_error != PRO_TK_NO_ERROR) {





ProWstringToString(pro_szErrBuf, pro_wszErrBuf);


ProUtilPrint(pro_szErrBuf);


ProUtilPrint("\n");


return pro_errorDll;


}


}


m_pro_bAutoPodLoaded = PRO_B_TRUE;


}


ProUtilPrint("Executing %s\n", m_strAutopodVersion.c_str());


//Check the version of Autopod


if(m_strAutopodVersion == "Autopod 2.0") {


//Setup the arguments


pro_error = ProArrayAlloc(1, sizeof(ProArgument), 1, (ProArray*)&pro_aArgInput);


PROUTIL_CALL_REPORT("ProArrayAlloc()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);


ProStringToWstring(pro_aArgInput[0].label, "msgDisplay");


pro_aArgInput[0].value.type = PRO_VALUE_TYPE_BOOLEAN;


pro_aArgInput[0].value.v.b = PRO_B_TRUE;





//Execute the AutoPod program


pro_error = ProToolkitTaskExecute(m_pro_hTkDllAutoPod, "AutoSetPods", pro_aArgInput, &pro_aArgOutput, &pro_errorDll);


PROUTIL_CALL_REPORT("ProToolkitTaskExecute()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);


//Free the input arguments


pro_error = ProArgumentProarrayFree(&pro_aArgInput);


PROUTIL_CALL_REPORT("ProArgumentProarrayFree()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);


}


else if(m_strAutopodVersion == "Autopod 3.0")


{


//Setup the arguments


pro_error = ProArrayAlloc(0, sizeof(ProArgument), 1, (ProArray*)&pro_aArgInput);


PROUTIL_CALL_REPORT("ProArrayAlloc()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);


//Execute the AutoPod program


pro_error = ProToolkitTaskExecute(m_pro_hTkDllAutoPod, "AutoSetPods", pro_aArgInput, &pro_aArgOutput, &pro_errorDll);


PROUTIL_CALL_REPORT("ProToolkitTaskExecute()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);


//Free the input arguments


pro_error = ProArgumentProarrayFree(&pro_aArgInput);


PROUTIL_CALL_REPORT("ProArgumentProarrayFree()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);


} 





//Free the output arguments


if(pro_aArgOutput != NULL) {


pro_error = ProArgumentProarrayFree(&pro_aArgOutput);


PROUTIL_CALL_REPORT("ProArgumentProarrayFree()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);


}


//Regenerate the model and repaint the screen


pro_error = PRO_TK_REGEN_AGAIN;


while(pro_error == PRO_TK_REGEN_AGAIN) {





pro_error = ProSolidRegenerate(m_pro_assyMfg, PRO_REGEN_NO_FLAGS);


PROUTIL_CALL_REPORT("ProSolidRegenerate()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR && pro_error!=PRO_TK_REGEN_AGAIN);


}


pro_error = ProWindowRepaint(PRO_VALUE_UNUSED);


PROUTIL_CALL_REPORT("ProWindowRepaint()", szFuncName, pro_error, pro_error!=PRO_TK_NO_ERROR);


return PRO_TK_NO_ERROR;


}
 
< http-equiv="Content-" content="text/; charset=utf-8">< name="ProgId" content="Word.">< name="Generator" content="Microsoft Word 11">< name="Originator" content="Microsoft Word 11">



Hi williaps,

Thanks for the prompt response.




I am copying the relevant code I am
using to make this call here -



------------------------------------------------------------ ----

ProArgument*
input_arguments = NULL;

ProArgument*
output_arguments = NULL;



status =
ProArrayAlloc( 1, sizeof(ProArgument), 1,
(ProArray*)&input_arguments);



ProStringToWstring(input_arguments[0].label,"I");

input_arguments[0].value.type=PRO_VALUE_TYPE_INT;

input_arguments[0].value.v.i=10;





ProError
function_return = PRO_TK_NO_ERROR;





status = ProToolkitTaskExecute( handle, "User_Test_Task", input_arguments,
&output_arguments, &function_return );

------------------------------------------------------------ ----



After execution of ProToolkitTaskExecute
[/i][/b]call, value of status is set to PRO_TK_E_NOT_FOUND[/i][/b].



Before making the above call the
corresponding dll is successfully loaded into the memory using following API call
 
I checked with DLL Export View Freeware and found that "User_Test_Task" is not listed as exported function.

I have used PRO_TK_DLL_EXPORT to export the function.



Am I missing
something here?





Thanks,

Kashish
 
Did you set your preprocessor definitions correctly as in the sample make files?


WIN32;


_DEBUG;


_CONSOLE;


PRO_MACHINE=29;


PRO_OS=4;


USE_ANSI_IOSTREAMS;


PRO_USE_VAR_ARG;


PRO_USE_VAR_ARGS;


If I were you then I would start over and use the custom Pro/ENGINEER WF 3.0 Project Wizard for VS .NET 2003 from www.felcosolutions.com. You may be missing some critical C/C++ or Linker settings.
 
< http-equiv="Content-" content="text/; charset=utf-8">< name="ProgId" content="Word.">< name="Generator" content="Microsoft Word 11">< name="Originator" content="Microsoft Word 11">





Hi Williaps,



Thanks for prompt responses and help.



It seems I am not using the correct options for building my
ProToolkit application. I
 
Hi Williaps,





Thanks a lot. PRO_OS=4; wasn't set. Now it's working fine.

Pro / Toolkit WF4.0 API wizard (Documentation available with WF4.0) suggest that the - ProArgument* input which is a ProArray of input arguments passed to the DLL shouldn't contain any ProValueData structure of type PRO_VALUE_TYPE_POINTER.

Can you suggest what wrong in supplying a pointer as input argument? Why shouldn't we send pointers? I checked it works fine.




Thanks,
 
I think the reason is that if you send a pointer to your external dll the memory location of where Pro/ENGINEER actually allocated the memory may change due to regenerations. You see, if you pass around a ProMdl object (event without an external dll) within your code, it may eventually crash your program with a memory access fault. It is better to pass around the ID and use Pro*Init() APIs to acquire a handle. Your program may have worked once but I wouldn't guarantee that it would work all of the time.
 

Sponsor

Back
Top