【发布时间】:2011-11-01 00:21:37
【问题描述】:
这是基本的,如何从 C# DllImport 调用下面的函数 SubscribeNewsFeed?
class LogAppender : public L_Append
{
public:
LogAppender()
: outfile("TestLog.txt", std::ios::trunc | std::ios::out)
, feedSubscribed(false)
{
outfile.setf(0, std::ios::floatfield);
outfile.precision(4);
}
void SubscribeNewsFeed()
{
someOtherCalls();
}
};
在我的 C# 程序中使用 DllImport 时,我无法弄清楚如何在此处包含类名:
class Program
{
[DllImport("LogAppender.dll")]
public static extern void SubscribeNewsFeed();
static void Main(string[] args)
{
SubscribeNewsFeed();
}
}
【问题讨论】:
-
即使在 C++ 中,你也需要实例化一个 LogAppender 来调用它。
标签: c# .net c++ unmanaged dllimport