Showing results for 
Search instead for 
Did you mean: 
Reply

list of dll functions

Solved!
Go to Solution
Highlighted

list of dll functions

Hi, I've tried to get list of all functions from current dll. Here is my code: tsErrChkMsgPopup( TS_StepGetModule (StepHandle, &errorInfo,&cviModule)); error = TS_CVIModuleAsCommonCModule (cviModule, &errorInfo, &commonCModule); sprintf(sztemp, "c:\\Temp\\%s", szdll); error = TS_CommonCModuleSetModulePath (commonCModule, &errorInfo, sztemp); error = TS_CVIModuleSetModuleType (commonCModule, &errorInfo, TSConst_CVIModuleType_DLL); error=TS_EngineGetAdapter (EngineHandle,&errorInfo, count,&commonCAdapter); error= TS_CommonCAdapterGetDllFunctions (commonCAdapter, &errorInfo, sztemp, &dll_func); Problem was found in the last row. Direct connection between commonCModule and commonCAdapter was not exist, so I ask from EngineHandle for commonCAdapter, because GetDllFunctions exist only for commonCAdapter. Can you help me with this ? best regards, branar
0 Kudos
Message 1 of 5 (669 Views)
Reply
0 Kudos
Solution
Accepted by topic author branar
‎08-27-2015 06:09 PM

Re: list of dll functions

You do not need a module to get a list of DLL functions. Here's some pseudocode for what you need to do:

 

CommonCAdapter adapter = Engine.GetAdapterByKeyName(AdapterKeyNames.FlexCVIAdapterKeyName);

DllFunctions functions = adapter.GetDllFunctions(path);

for (int i = 0; i < functions.Count; i++)

{

DllFunction function = functions[i];

string functionName = function.DisplayName;

// Do something with functionName.

}


0 Kudos
Message 2 of 5 (648 Views)
Reply
0 Kudos

Re: list of dll functions

Hi Eric,

 

Thank you for your answer. I was created similar code in CVI with addition that function parameters (if exist) will be writen in txt file. However, number of parameters, for some reason are bigger for one. If function has only two parameters (testData and testError), still anwer is 3. Here is code for this:

 

error = TS_EngineGetAdapterByKeyName (EngineHandle, &errorInfo, "C/CVI Flexible Prototype Adapter", &commonCAdapter);
error= TS_CommonCAdapterGetDllFunctions (commonCAdapter, &errorInfo, sztemp, &dll_func);
error = TS_DllFunctionsGetCount (dll_func, &errorInfo, &count);
max=count;
status=0;
i=0;
count1=0;
while (max>0){
CA_VariantSetInt(&itemIndex,status);
error = TS_DllFunctionsGetItem (dll_func, &errorInfo, itemIndex, &dll_func1);
error = TS_DllFunctionGetDisplayName (dll_func1, &errorInfo, &szStepID);
error = TS_DllFunctionGetHasParameterInformation (dll_func1, &errorInfo, &removedfromCache);	
sprintf(buffer,"%s :\n",szStepID);
error = WriteStringToFile (FILE_dll, buffer);
error = TS_CommonCModuleSetFunctionName (commonCModule, &errorInfo,szStepID);
error = TS_ModuleLoadPrototype (commonCModule, &errorInfo, NULL, &removedfromCache);
error = TS_CVIModuleGetParameters (cviModule, &errorInfo, &cviParameters);
error = TS_CVIParametersGetCount (cviParameters, &errorInfo, &count1);
for (i=1;i<count1;i++)
{
CA_VariantSetInt(&itemIndex,i);
error= TS_CVIParametersGetItem (cviParameters, &errorInfo, itemIndex, &cviParameter);
error = TS_CVIParameterAsCommonCParameter (cviParameter, &errorInfo, &commonCParameter);
error = TS_CommonCParameterGetParameterName (commonCParameter, &errorInfo, &szparam_name);
error = TS_CommonCParameterGetDescription (commonCParameter, &errorInfo, &szparam_desc);
sprintf(buffer,"%s, %s\n",szparam_name,szparam_desc);
error = WriteStringToFile (FILE_dll, buffer);
CAFREEOBJ (cviParameter);
CAFREEOBJ (commonCParameter);
}
count1=0;
status++;
max--;
}
					

best regards,

branar

0 Kudos
Message 3 of 5 (629 Views)
Reply
0 Kudos

Re: list of dll functions

TestStand treats the function return value as a parameter so the collection of CVIParameters will always contain one more item than the number of function parameters. The return value is the first item in the CVIParameters collection.

0 Kudos
Message 4 of 5 (622 Views)
Reply
0 Kudos

Re: list of dll functions

Hi Eric,

 

Thank you for your clarifications.

 

best regards,

branar

0 Kudos
Message 5 of 5 (605 Views)
Reply
0 Kudos