CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  VC.NET

调用dll出错,帮忙看看。

楼主Johnnyxy(风里密码)2005-07-10 20:16:06 在 .NET技术 / VC.NET 提问

#include   "stdafx.h"  
  using   namespace   std;  
  typedef   char*   (_stdcall   *MYDLLFUNC)(const   char*   s,char   *szOut);  
  int   _tmain(int   argc,   _TCHAR*   argv[])  
  {  
  char*   out;  
  HMODULE   hDll   =::LoadLibrary("dll.dll");  
  if(hDll)  
  {  
  MYDLLFUNC   myDllFunc   =   (MYDLLFUNC)::GetProcAddress(hDll,(LPCSTR)1);  
  if(myDLLFunc)  
  {  
  char*   ch;  
  out   =   myDllFunc("abc",ch);  
  }  
  ::FreeLibrary(hDll);  
  }  
  cout<<out<<endl;  
  return   0;  
  }  
   
  为什么会出现:  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(19):   error   C2039:   “FreeLibrary”   :   不是“operator``global   namespace''”的成员  
   
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(13):   error   C2039:   “GetProcAddress”   :   不是“operator``global   namespace''”的成员  
   
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(10):   error   C2039:   “LoadLibrary”   :   不是“operator``global   namespace''”的成员  
   
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(13):   error   C2059:   语法错误   :   “)”  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(10):   error   C2065:   “hDll”   :   未声明的标识符  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(10):   error   C2065:   “HMODULE”   :   未声明的标识符  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(13):   error   C2065:   “LPCSTR”   :   未声明的标识符  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(14):   error   C2065:   “myDLLFunc”   :   未声明的标识符  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(13):   error   C2143:   语法错误   :   缺少“)”(在“常数”的前面)  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(10):   error   C2146:   语法错误   :   缺少“;”(在标识符“hDll”的前面)  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(19):   error   C3861:   “FreeLibrary”:   即使使用参数相关的查找,也未找到标识符  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(13):   error   C3861:   “GetProcAddress”:   即使使用参数相关的查找,也未找到标识符  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(11):   error   C3861:   “hDll”:   即使使用参数相关的查找,也未找到标识符  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(13):   error   C3861:   “hDll”:   即使使用参数相关的查找,也未找到标识符  
  c:\Documents   and   Settings\JIMMY\My   Documents\Visual   Studio   Projects\C++.net\testdll\testdll.cpp(19):   error   C3861:   “hDll”:   即使使用参数相关的查找,也未找到标识符  
  的错误啊???? 问题点数:20、回复次数:5Top

1 楼Johnnyxy(风里密码)回复于 2005-07-10 22:38:37 得分 0

这里的人气不是很旺阿Top

2 楼yeyuboy(海绵)回复于 2005-07-11 09:27:09 得分 7

再加个#inlcude   <windows.h>试试Top

3 楼54783szg(百里洲)回复于 2005-07-11 10:08:18 得分 6

改成下面这样试试,另外不知你是不是在MFC下建的工程?  
  #include   "stdafx.h"  
  using   namespace   std;  
  typedef   char*   (WINAPI*   MYDLLFUNC)(const   char*   s,char   *szOut);  
   
  int   _tmain(int   argc,   _TCHAR*   argv[])  
  {  
  char*   out;  
  HINSTANCE   hDll   =LoadLibrary("dll.dll");  
  if(hDll)  
  {  
  MYDLLFUNC   myDllFunc   =   (MYDLLFUNC)GetProcAddress(hDll,(LPCSTR)1);  
  if(myDLLFunc)  
  {  
  char*   ch;  
  out   =   myDllFunc("abc",ch);  
  }  
  ::FreeLibrary(hDll);  
  }  
  cout<<out<<endl;  
  return   0;  
  }Top

4 楼jenycheng(听,雪的声音)回复于 2005-07-11 10:10:35 得分 7

#include   <windows.h>Top

5 楼Johnnyxy(风里密码)回复于 2005-07-12 08:40:51 得分 0

恩,谢谢大家已经解决  
  就是要在stdafx.h里面+上  
  #include   <windows.h>  
  #include   <winbase.h>Top

相关问题

  • DLL调用出错
  • 调用.dll出错
  • 弱问:DLL调用出错
  • Dll调用出错?who can help me?
  • vc调用vc的DLL出错??
  • Dll的调用为什么会出错?
  • 调用DLL出错,请高手指教!
  • 动态调用DLL出错为何?
  • dll调用出错,附源码
  • 调用DLL 出错,以知代码 ?

关键词

  • dll
  • mydllfunc
  • hdll
  • stdafx
  • ch
  • char
  • include

得分解答快速导航

  • 帖主:Johnnyxy
  • yeyuboy
  • 54783szg
  • jenycheng

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo