Jump to content

Using Call Library Function for dll


Recommended Posts

Sorry, I am new to using call library function and don't know where to begin. I tried using the import shared library (.dll) tool to create vi's for each function in my dll. When I load the supplied .h file it seems like my definitions are not recognized. could someone please show me how to create a labview vi for calling the functions in the attached .dll? It's been several years since I've dealt with C code/and defintions and variable types.

Thanks

Steve M.

Download File:post-7342-1170954787.zip

Link to comment
Sorry, I am new to using call library function and don't know where to begin. I tried using the import shared library (.dll) tool to create vi's for each function in my dll. When I load the supplied .h file it seems like my definitions are not recognized. could someone please show me how to create a labview vi for calling the functions in the attached .dll? It's been several years since I've dealt with C code/and defintions and variable types.

This header file uses a very strange and unusal way to define the function prototypes in the DLL. In fact it does not define any prototypes but just function pointer types. That's definitely not a standard way to incorporate this DLL into once own code even in C.

Try to change for all functions

DWORD (*MPUSBGetDLLVersion)(void);

to

DWORD MPUSBGetDLLVersion(void);

basically removing the brackets around the function names and also the * in front of the function name and then try to import this again with the DLL import tool.

Now it should work.

Rolf Kalbermatter

Link to comment

This header file uses a very strange and unusal way to define the function prototypes in the DLL. In fact it does not define any prototypes but just function pointer types. That's definitely not a standard way to incorporate this DLL into once own code even in C.

Try to change for all functions

DWORD (*MPUSBGetDLLVersion)(void);

to

DWORD MPUSBGetDLLVersion(void);

basically removing the brackets around the function names and also the * in front of the function name and then try to import this again with the DLL import tool.

Now it should work.

Rolf Kalbermatter

Thanks Rolf

Another Question. Below is the .h file

#ifndef _MPUSBAPI_H_

#define _MPUSBAPI_H_

#define MPUSB_FAIL 0

#define MPUSB_SUCCESS 1

#define MP_WRITE 0

#define MP_READ 1

// MAX_NUM_MPUSB_DEV is an abstract limitation.

// It is very unlikely that a computer system will have more

// then 127 USB devices attached to it. (single or multiple USB hosts)

#define MAX_NUM_MPUSB_DEV 127

DWORD (*MPUSBGetDLLVersion)(void);

DWORD (*MPUSBGetDeviceCount)(PCHAR pVID_PID);

HANDLE (*MPUSBOpen)(DWORD instance, // Input

PCHAR pVID_PID, // Input

PCHAR pEP, // Input

DWORD dwDir, // Input

DWORD dwReserved); // Input <Future Use>

DWORD (*MPUSBRead)(HANDLE handle, // Input

PVOID pData, // Output

DWORD dwLen, // Input

PDWORD pLength, // Output

DWORD dwMilliseconds); // Input

DWORD (*MPUSBWrite)(HANDLE handle, // Input

PVOID pData, // Input

DWORD dwLen, // Input

PDWORD pLength, // Output

DWORD dwMilliseconds); // Input

DWORD (*MPUSBReadInt)(HANDLE handle, // Input

PVOID pData, // Output

DWORD dwLen, // Input

PDWORD pLength, // Output

DWORD dwMilliseconds); // Input

BOOL (*MPUSBClose)(HANDLE handle);

#endif

Labview does not seem to understand PVOID,DWORD,PWORD, and BOOL datatypes. I beleive these are DELPHI datatypes. What would you recommend me using for Labview recognized datatypes instead? also to I need to define my variable name as weill i.e. #define Data void

Thanks for the help

Steve M.

Link to comment

Labview does not seem to understand PVOID,DWORD,PWORD, and BOOL datatypes. I beleive these are DELPHI datatypes. What would you recommend me using for Labview recognized

datatypes instead? also to I need to define my variable name as weill i.e. #define Data void

These are typical Windows SDK types. But your header file does not include any other header files so it is syntactically not right. A C compiler could not understand it either without additional includes defining those types.

Bascially that whole header file looks like a big mess to me. I'm surprised that Microchip does release something like this.

There have been various posts here on LAVA and the Developer Exchange showing the actual type definition of those Windows SDK types. Adding them to the top of your header file seems to be the most simple solution.

I do not understand your question about defining your own data. I would say no but can't be sure.

Rolf Kalbermatter

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.