LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I access the same function in a DLL and in an application?

I need to be able to run the same function from within a DLL AND from an appication that uses the DLL. For example, in the DLL, I need to export a function that initializes a few instruments. This function would make instrument function calls. These same instrument function calls need to be accessible from an application that uses the DLL.
0 Kudos
Message 1 of 3
(2,826 Views)
If I understand you question correctly, you could have a function that is local to the DLL that actually performs the instrument function calls. The exported function,i.e. the ones that can be accessed from the outside world would then just call this local function.
So that the same code is used in both cases...

eg...

int localFunction()
{
instrumentFunction1();
instrumentFunction2();
return 1;
}

int DLLEXPORT exportableFunction()
{
localFunction();
return 1;
}
0 Kudos
Message 2 of 3
(2,826 Views)
You can call the same function from within the DLL and from an external app that calls the DLL. You don't need to create a new function to do this.
I create a separate .h file for functions I want to export. I copy prototypes from the internal .h or .c files to the export .h file and change the type to extern int __cdecl. I add the export .h file to my DLL project, but I don't #include the export .h file in any .c or .h file in my DLL project. I #include it in my app that calls the DLL functions. See additional details in my answer here.
0 Kudos
Message 3 of 3
(2,826 Views)