LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i access a function inside a dll?

I' trying to access a dll's function but i can't. I have the header, dll and the type library. The function is declared as
short int __far DLLEXPORT DLLSTDCALL Download_Can( char *FileDescription, short int port_num, short int slot_num );

When i try to make my own lib i get an error in the DLLSTDCALL tag. Why is this...do i need to make a special consideration? I just need no add the .lib to my project in order to get access to the function in the dll, or i need something else? When i do this, i get a link error that says that the function i'm triying to access was not found.
0 Kudos
Message 1 of 3
(3,072 Views)
Seeing as you know the definition, but don?t have the header, you can declare a typedef as shown below:

typedef int (__stdcall *fnPtr)( char *FileDescription, short int port_num, short int slot_num);

You will then need to load the DLL using :

hRef=LoadLibrary(?Your DLL Name?);

After loading, you now need to get the address of the function you want to call:

nameFn=(fnPtr)GetProcAddress(hRef,"Download_Can");

And to call it, you use:

nameFn (FileDescription, port_num, slot_num);


All of those functions above are from the Windows SDK, so if you need any info on them, do a search using the function names.

If you need anymore help, ask away

Regards

Chris
0 Kudos
Message 2 of 3
(3,071 Views)
Oops..Slight error, you may have to change the typedef to use short int, and not int. Have a play and see what you find out.

Chris
0 Kudos
Message 3 of 3
(3,071 Views)