this should be so simple....here is the code in my simple "C" dll
#define DllExport __declspec(dllexport)
#include <time.h>
//DllExport
long gettime(void);
long gettime()
{
time_t tt = time(NULL);
return (long)tt;
}
--------------------------------------------------------------------------
here is the import in my C# app
[DllImport("ctime.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern long gettime();
-------------------------------------------
I've tried several different CallingConventions and nothing same thing
"Unable to find entry point named gettime in dll ctime.dll
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uz**************@TK2MSFTNGP09.phx.gbl...
Tim,
You should have received an error when you added it to your project.
If you have a function that is exported by a DLL, you need to call it
through the P/Invoke layer. If the dll is somewhere in the path where
LoadLibrary will find it, you can do this:
[DllImport("<dll name here>.dll")]
static extern int myfunc();
And then call the dll function in managed code.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Tim Greenwood" <tim_greenwood A-T yahoo D-O-T com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...I am at my wits end here. I have a simple project with one global
function returning a long value.
__declspec(dllexport) long myfunc()
{
}
I've built the dll, added it as a reference to my C# project. Now how in
the world do I reference "myfunc" ????
It totally eludes me.
Many thanks for any help here.