Compiling C code functions to call from VB
Hi
I have a chip I need to reconfigure via a VB app. The company provides a C code API to do this (i.e. their software generates *.c, *.h files for us to call).
I don't know C, but I want to compile it as a dll file to reference from my VB project. The files are plain C. Which wizard settings should I use, so that I can compile and link to it to access their functions from my VB code?
I have tried to do this, but keep getting an error message saying it could not add it as a reference: ...make sure file is accessible, and that it is a valid COM component. ?
Thanks
Hi - sorry didn't make that clear enough. I have Visual Studio Professional, so it will compile the C fine. As I said, I have already tried compiling it and referencing the dll file - Visual Studio won't let me add it as a reference and gives the error message I quoted.
Thanks,
k.
Probably because it's a 'standard' DLL: you don't need to add a reference.
As long as the DLL is in the accessable path (usually the application folder is easiest) you can access any exposed functions by making a declaration (PInvoke, platform invocation, as it's referred to) just like the Win32 APIs. e.g.:
Public Declare Auto Function CloseHandle Lib "kernel32" (ByVal hObject As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean