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

[601 byte] By [biscuitlad] at [2007-12-25]
# 1

you will need a c compiler to compile your c code into a dll...then you can add a reference to the C dll in your vb project and access the public members. There are alot of free c compilers out there:

http://www.htsoft.com/products/PACIFICc.php

http://www.thefreecountry.com/compilers/cpp.shtml

DMan1 at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
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.

biscuitlad at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

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

SJWhiteley at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
Thanks for the reply - I looked up PInvoke and found information relating to DLLImportAttribute, which looks like it will do the trick.

Thanks.

biscuitlad at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...