问题如下:
c.h文件中:
extern "C" __declspec(dllexport)int F();
c.cpp文件中
#include <iostream.h>
int F()
{
cout<<"sssssss"<<endl;
return 1;
}
在C#中如下调用:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;namespace console
{
class Program
{
[DllImport("b.exe", EntryPoint = "F", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
static extern int F(); static void Main(string[] args)
{
F();
}
}
}
出现如题的问题。请高手指点迷津
c.h文件中:
extern "C" __declspec(dllexport)int F();
c.cpp文件中
#include <iostream.h>
int F()
{
cout<<"sssssss"<<endl;
return 1;
}
在C#中如下调用:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;namespace console
{
class Program
{
[DllImport("b.exe", EntryPoint = "F", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
static extern int F(); static void Main(string[] args)
{
F();
}
}
}
出现如题的问题。请高手指点迷津
b.exe 编译为b.dll
如果去掉 cout<<"sssssss"<<endl;就行,搞不懂
或者,在.net下使用managed C++重新编写C\C++的原文件,然后编译成托管dll即可!