关于调用 c++ 函数

teal 2003-08-22 06:25:47
写了一个 c++ 的程序,有 *.ccp 和 *.h 文件,
现在要在窗口的一个按钮事件上,调用这个函数,我该怎么做?

我是菜鸟,谢谢 各位大哥先
...全文
59 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
teal 2003-08-23
  • 打赏
  • 举报
回复
up
teal 2003-08-22
  • 打赏
  • 举报
回复
如果生成 teal.lib 可不可以调用呢?
在 teal.h 中 ,把 void tealFunction(void) 申明为 外部函数??
panyee 2003-08-22
  • 打赏
  • 举报
回复
teal.h中把它声明为外部可调用
teal 2003-08-22
  • 打赏
  • 举报
回复
panyee(快乐王子) 哥哥:

很抱歉,小弟还没有看明白:麻烦您在详细的说明一下:

小第有一个 teal.h 和 teal.ccp文件,编译成了teal.dll 文件
里面有一个void tealFunction(void) 函数,然后在 void main() 中调用
是不是这样:

#using <mscorlib.dll>
using namespace System::Runtime::InteropServices; // for DllImportAttribute

namespace SysWin32
{
[DllImport("teal.dll", EntryPoint = "tealFunction", CharSet = Unicode)]
void tealFunction(void);
}

void main( )
{
tealFunction();
}

??
请您继续 指教!

panyee 2003-08-22
  • 打赏
  • 举报
回复
你要把.ccp和.h编译成一个.dll文件, 再供vc.net调用

例如:


#using <mscorlib.dll>
using namespace System::Runtime::InteropServices; // for DllImportAttribute

namespace SysWin32
{
[DllImport("user32.dll", EntryPoint = "MessageBox", CharSet = Unicode)]
int MessageBox(void* hWnd, wchar_t* lpText, wchar_t* lpCaption, unsigned int uType);
}

void main( )
{
SysWin32::MessageBox( 0, L"Hello world!", L"Greetings", 0 );
}
panyee 2003-08-22
  • 打赏
  • 举报
回复
你要把.ccp和.h编译成一个.dll文件, 再供vc.net调用

例如:


#using <mscorlib.dll>
using namespace System::Runtime::InteropServices; // for DllImportAttribute

namespace SysWin32
{
[DllImport("user32.dll", EntryPoint = "MessageBox", CharSet = Unicode)]
int MessageBox(void* hWnd, wchar_t* lpText, wchar_t* lpCaption, unsigned int uType);
}

void main( )
{
SysWin32::MessageBox( 0, L"Hello world!", L"Greetings", 0 );
}

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧