c++builder怎样调用c#作的dll啊 _net技术 - c# - csdn社区 community_csdn_net.htm

来自「Borland C++ 动态链接库调用方法使用」· HTM 代码 · 共 359 行 · 第 1/2 页

HTM
359
字号
2003-09-02 20:56:31 得分 <EM>6</EM></SPAN></H3>
<P>我想也许你可以用VC.NET包装一下,不过无论如何你的程序都脱不开.NET &nbsp; Framework<A 
href="http://topic.csdn.net/t/20030902/08/2213237.html#">Top</A></P>
<H3><STRONG><A class=anchor name=r_15101328>8 楼</A>Behard(我爱天安门)<INPUT class=user1 title="一级用户 该版得分小于等于100分" type=button></STRONG><SPAN>回复于 
2003-09-03 09:11:01 得分 <EM>3</EM></SPAN></H3>
<P>没有 &nbsp; VC.net &nbsp; 没有权利发言<A 
href="http://topic.csdn.net/t/20030902/08/2213237.html#">Top</A></P>
<H3><STRONG><A class=anchor name=r_15164513>9 楼</A>hongliqiu(在火中)<INPUT class=user1 title="一级用户 该版得分小于等于100分" type=button></STRONG><SPAN>回复于 
2003-09-05 09:40:11 得分 <EM>3</EM></SPAN></H3>
<P>不知道,听课来了。<A 
href="http://topic.csdn.net/t/20030902/08/2213237.html#">Top</A></P>
<H3><STRONG><A class=anchor name=r_15165141>10 楼</A>wenyongjie(我们的目标是:没有蛀牙!!)<INPUT class=user1 title="一级用户 该版得分小于等于100分" type=button></STRONG><SPAN>回复于 
2003-09-05 09:55:10 得分 0 </SPAN></H3>
<P>我作了一下,没有成功,现把代码帖出,各位看下有哪些要改一下! &nbsp; <BR>&nbsp; 这是C#的DLL &nbsp; <BR>&nbsp; 
using &nbsp; System; &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; namespace &nbsp; CBDLL 
&nbsp; <BR>&nbsp; { &nbsp; <BR>&nbsp; /// &nbsp; &lt;summary&gt; &nbsp; 
<BR>&nbsp; /// &nbsp; Class1 &nbsp; 的摘要说明。 &nbsp; <BR>&nbsp; /// &nbsp; 
&lt;/summary&gt; &nbsp; <BR>&nbsp; public &nbsp; class &nbsp; Class1 &nbsp; 
<BR>&nbsp; { &nbsp; <BR>&nbsp; public &nbsp; Class1() &nbsp; <BR>&nbsp; { &nbsp; 
<BR>&nbsp; // &nbsp; <BR>&nbsp; // &nbsp; TODO: &nbsp; 在此处添加构造函数逻辑 &nbsp; 
<BR>&nbsp; // &nbsp; <BR>&nbsp; } &nbsp; <BR>&nbsp; public &nbsp; string &nbsp; 
test(string &nbsp; str) &nbsp; <BR>&nbsp; { &nbsp; <BR>&nbsp; return(str); 
&nbsp; <BR>&nbsp; } &nbsp; <BR>&nbsp; } &nbsp; <BR>&nbsp; } &nbsp; <BR>&nbsp; CB 
&nbsp; 动态调用 &nbsp; <BR>&nbsp; private: // &nbsp; User &nbsp; declarations &nbsp; 
<BR>&nbsp; String &nbsp; (__stdcall &nbsp; *test)(String &nbsp; str);//声明 &nbsp; 
<BR>&nbsp; &nbsp; <BR>&nbsp; void &nbsp; __fastcall &nbsp; 
TForm1::Button1Click(TObject &nbsp; *Sender)//双击Button1调用 &nbsp; <BR>&nbsp; { 
&nbsp; HINSTANCE &nbsp; DLLInst &nbsp; = &nbsp; NULL; &nbsp; <BR>&nbsp; &nbsp; 
&nbsp; String &nbsp; s; &nbsp; <BR>&nbsp; &nbsp; &nbsp; if( &nbsp; NULL &nbsp; 
== &nbsp; DLLInst &nbsp; ) &nbsp; DLLInst &nbsp; = &nbsp; 
LoadLibrary("CBDLL.dll"); &nbsp; //上面的 &nbsp; Dll &nbsp; <BR>&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; if &nbsp; (DLLInst) &nbsp; { &nbsp; <BR>&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; test=(String &nbsp; 
(__stdcall*)(String &nbsp; str)) &nbsp; GetProcAddress(DLLInst,"_test@0"); 
&nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
if &nbsp; (test) &nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; s=test(Edit1-&gt;Text); &nbsp; &nbsp; 
&nbsp; ShowMessage(s); &nbsp; &nbsp; &nbsp; } &nbsp; <BR>&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; 
ShowMessage("不能取得函数test指针"); &nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } 
&nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; 
ShowMessage("加载CBDLL.dll错误!"); &nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
FreeLibrary(DLLInst); &nbsp; <BR>&nbsp; } &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 
出现如下提示: &nbsp; 不能取得函数test指针<A 
href="http://topic.csdn.net/t/20030902/08/2213237.html#">Top</A></P>
<H3><STRONG><A class=anchor name=r_15855833>11 楼</A>yhz(耗子)<INPUT class=user1 title="一级用户 该版得分小于等于100分" type=button></STRONG><SPAN>回复于 
2003-09-28 15:54:18 得分 <EM>6</EM></SPAN></H3>
<P>你用 &nbsp; depends &nbsp; 去检查一下你的 &nbsp; test &nbsp; 的名字还是不是 &nbsp; test 
&nbsp; ??? &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 我现在手头上没有 &nbsp; 
VC.net,不过我估计在编译的时候,编译器把输出名字改了。 &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 或者你在 &nbsp; 
DLL &nbsp; 的输出函数里面加上 &nbsp; __stdcall &nbsp; 试试看?<A 
href="http://topic.csdn.net/t/20030902/08/2213237.html#">Top</A></P>
<H3><STRONG><A class=anchor name=r_15857008>12 楼</A>zhouzhouzhou(人生程序)<INPUT class=user4 title="四级用户 该版得分小于等于2000分,大于1000分" type=button></STRONG><SPAN>回复于 
2003-09-28 16:23:10 得分 <EM>3</EM></SPAN></H3>
<P>不是吧, &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 暈<A 
href="http://topic.csdn.net/t/20030902/08/2213237.html#">Top</A></P>
<H3><STRONG><A class=anchor name=r_15861457>13 楼</A>storm97(风暴不再)<INPUT class=star2 title="二星用户 该版得分小于等于30000分,大于10000分" type=button></STRONG><SPAN>回复于 
2003-09-28 18:37:32 得分 <EM>11</EM></SPAN></H3>
<P>http://www.csdn.net/develop/article/21/21259.shtm<A 
href="http://topic.csdn.net/t/20030902/08/2213237.html#">Top</A></P>
<H4><STRONG>相关问题</STRONG></H4>
<DIV class=relation>
<UL>
  <LI><A href="http://topic.csdn.net/t/20021223/16/1292303.html" 
  rel=external>简单调用DLL函数C++ Builder !</A> 
  <LI><A href="http://topic.csdn.net/t/20010912/10/283360.html" rel=external>C++ 
  Builder中如何调用VC++编写的.dll?</A> 
  <LI><A href="http://topic.csdn.net/t/20011026/13/341543.html" 
  rel=external>如何在DELPHI中调用C++ BUILDER写的DLL文件? </A>
  <LI><A href="http://topic.csdn.net/t/20011208/19/410659.html" 
  rel=external>用C++Builder开发的DLL怎样在Delphi中调用?</A> 
  <LI><A href="http://topic.csdn.net/t/20011214/17/421860.html" rel=external>C++ 
  Builder 如何调用动态连接库(*.DLL)中的函数</A> 
  <LI><A href="http://topic.csdn.net/t/20020301/10/548846.html" rel=external>C++ 
  Builder中调用delphi做的dll的问题</A> 
  <LI><A href="http://topic.csdn.net/t/20020422/11/665898.html" 
  rel=external>在PB中如何调用C++Builder开发的DLL</A> 
  <LI><A href="http://topic.csdn.net/t/20020529/14/762024.html" 
  rel=external>关于C++ Builder中 调用DLL的问题?</A> 
  <LI><A href="http://topic.csdn.net/t/20050304/14/3824661.html" 
  rel=external>delphi下的dll如何改到c++builder下调用???</A> 
  <LI><A href="http://topic.csdn.net/t/20050308/13/3833762.html" 
  rel=external>vb的dll如何在c++builder中调用?</A> </LI></UL></DIV></DIV></DIV>
<DIV id=sidebar>
<H3>关键词</H3>
<DIV>
<UL>
  <LI><A href="http://tag.csdn.net/tag/.net/" rel=external>.net</A> 
  <LI><A href="http://tag.csdn.net/tag/c#/" rel=external>c#</A> 
  <LI><A href="http://tag.csdn.net/tag/c++builder/" rel=external>c++builder</A> 
  <LI><A href="http://tag.csdn.net/tag/函数/" rel=external>函数</A> 
  <LI><A href="http://tag.csdn.net/tag/动态库/" rel=external>动态库</A> 
  <LI><A href="http://tag.csdn.net/tag/指针/" rel=external>指针</A> 
  <LI><A href="http://tag.csdn.net/tag/应用程序/" rel=external>应用程序</A> 
  <LI><A href="http://tag.csdn.net/tag/开发平台/" rel=external>开发平台</A> 
  <LI><A href="http://tag.csdn.net/tag/文件/" rel=external>文件</A> 
  <LI><A href="http://tag.csdn.net/tag/连接/" rel=external>连接</A> </LI></UL></DIV>
<H3>得分解答快速导航</H3>
<DIV>
<UL>
  <LI>帖主:<A 
  href="http://topic.csdn.net/t/20030902/08/2213237.html#Top">WYJBCB</A> 
  <LI><A 
  href="http://topic.csdn.net/t/20030902/08/2213237.html#r_15078236">Iamsnowgirl</A> 

  <LI><A 
  href="http://topic.csdn.net/t/20030902/08/2213237.html#r_15093641">yhz</A> 
  <LI><A 
  href="http://topic.csdn.net/t/20030902/08/2213237.html#r_15094081">zjqyb</A> 
  <LI><A 
  href="http://topic.csdn.net/t/20030902/08/2213237.html#r_15094609">ThinkX</A> 
  <LI><A 
  href="http://topic.csdn.net/t/20030902/08/2213237.html#r_15101328">Behard</A> 
  <LI><A 
  href="http://topic.csdn.net/t/20030902/08/2213237.html#r_15164513">hongliqiu</A> 

  <LI><A 
  href="http://topic.csdn.net/t/20030902/08/2213237.html#r_15855833">yhz</A> 
  <LI><A 
  href="http://topic.csdn.net/t/20030902/08/2213237.html#r_15857008">zhouzhouzhou</A> 

  <LI><A 
  href="http://topic.csdn.net/t/20030902/08/2213237.html#r_15861457">storm97</A> 
  </LI></UL></DIV>
<H3>相关链接</H3>
<DIV>
<UL>
  <LI><A href="http://dotnet.csdn.net/" target=_blank>CSDN .NET频道</A> 
  <LI><A 
  href="http://www.dearbook.com.cn/Book/SearchBook.aspx?sortid=6&amp;sorttype=smallsort" 
  target=_blank>.NET类图书</A> 
  <LI><A 
  href="http://www.dearbook.com.cn/Book/SearchBook.aspx?sortid=10&amp;sorttype=smallsort" 
  target=_blank>C#类图书</A> 
  <LI><A href="http://www.codechina.net/resource/sort.php/243" 
  target=_blank>.NET类源码下载</A> </LI></UL></DIV>
<H3>广告也精彩</H3>
<DIV>
<SCRIPT 
src="C++Builder怎样调用C#作的DLL啊 _NET技术 - C# - CSDN社区 community_csdn_net.files/show_ads.js" 
type=text/javascript></SCRIPT>
</DIV>
<H3>反馈</H3>
<DIV>请通过下述方式给我们反馈<BR><IMG alt=反馈 
src="C++Builder怎样调用C#作的DLL啊 _NET技术 - C# - CSDN社区 community_csdn_net.files/feedback.gif"></DIV></DIV>
<DIV class=clear></DIV></DIV>
<DIV class=CSDN-PHF id=CSDNPF>
<HR>
<A class=biaoshi 
href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010" 
rel=external>&nbsp;</A> 
<DIV><A href="http://www.csdn.net/intro/intro.asp?id=2" rel=external>网站简介</A>-<A 
href="http://www.csdn.net/intro/intro.asp?id=5" rel=external>广告服务</A>-<A 
href="http://www.csdn.net/map/map.shtm" rel=external>网站地图</A>-<A 
href="http://www.csdn.net/help/help.asp" rel=external>帮助</A>-<A 
href="http://www.csdn.net/intro/intro.asp?id=9" rel=external>联系方式</A>-<A 
href="http://job.csdn.net/Jobs/f9c75c9f2ad14404a604669b757b9ed0/viewcompany.aspx" 
rel=external>诚聘英才</A>-<A href="http://www.csdn.net/english/" 
rel=external>English</A>-<A 
href="javascript:navigate('mai'%20+%20'lto:'%20+%20'webm'%20+%20'aster@c'%20+%20'sdn.n'+'et?subject=向CSDN报告问题')" 
rel=external>问题报告</A></DIV>
<DIV>北京百联美达美数码科技有限公司&nbsp;&nbsp;版权所有&nbsp;&nbsp;京 ICP 证 020026 号</DIV>
<DIV>Copyright © 2000-2006, CSDN.NET, All Rights Reserved</DIV>
<SCRIPT 
src="C++Builder怎样调用C#作的DLL啊 _NET技术 - C# - CSDN社区 community_csdn_net.files/counter.js" 
type=text/javascript></SCRIPT>

<SCRIPT 
src="C++Builder怎样调用C#作的DLL啊 _NET技术 - C# - CSDN社区 community_csdn_net.files/jsframework.js" 
type=text/javascript></SCRIPT>

<SCRIPT type=text/javascript>/*<![CDATA[*/Include("Csdn.IM.NoticeWindow");/*]]>*/</SCRIPT>

<SCRIPT 
src="C++Builder怎样调用C#作的DLL啊 _NET技术 - C# - CSDN社区 community_csdn_net.files/clickeye.js"></SCRIPT>

<HR>
</DIV></DIV></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?