CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  VB.NET

弱弱的问

楼主xiangzhong(刀含梦)2006-03-02 17:38:56 在 .NET技术 / VB.NET 提问

如何将dll里面的函数声明为静态方法?谢谢 问题点数:20、回复次数:8Top

1 楼zhanqiangz(闲云野鹤-Overriding)回复于 2006-03-02 18:23:24 得分 0

dll   里的都是编译好的如何重新声明?Top

2 楼xiangzhong(刀含梦)回复于 2006-03-02 21:45:31 得分 0

我意思是能不能用上shared关键词将其设置为静态的?在declare的时候或者是dllimport的时候Top

3 楼wuyi8808(空间/IV)回复于 2006-03-02 21:48:31 得分 0

不行.  
   
  在declare的时候或者是dllimport的时候不可能改变dll里的函数的属性.  
  Top

4 楼xiangzhong(刀含梦)回复于 2006-03-02 22:34:52 得分 0

那我怎么将一个自定义类型的参数传递给dll函数呢?是通过引用传递的,我现在运行老是提示:未将引用设置到对象实例的错误,代码如下,改如何解决?  
  Imports   System.Runtime.InteropServices  
  Public   Class   Form1  
          Inherits   System.Windows.Forms.Form  
          'is   used   by   DRV_DioWriteBit   function  
          <StructLayout(LayoutKind.Sequential)>   Structure   PT_DioWriteBit  
                Public   Port   As   Short  
                Public   bit   As   Short  
                Public   state   As   Short  
          End   Structure  
   
            Public   Class   class1  
                  '声明函数  
                  Declare   Auto   Function   DRV_DioWriteBit   Lib   "adsapi32.dll"   _  
                            (ByVal   DriverHandle   As   Long,     ByVal   DioWriteBit   As   PT_DioWriteBit)   As   Integer  
          End   Class  
   
          Private   Sub   Form1_Click(ByVal   sender   As   Object,   ByVal   e   As   System.EventArgs)   Handles   MyBase.Click  
                  Try                    
                          Dim   ptDioWriteBit   As   New   PT_DioWriteBit  
                          ptDioWriteBit.Port   =   0  
                          ptDioWriteBit.bit   =   1  
                          ptDioWriteBit.state   =   1  
   
                          Dim   newClass1   As   New   class1  
                          'newClass1.DRV_DioWriteBit(deviceHandle,   ptDioWriteBit)这句执行出错  
                          ’错误提示如上面我说的,该如何改呢?  
                          errCde   =   newClass1.DRV_DioWriteBit(deviceHandle,   ptDioWriteBit)  
                          Catch   ex   As   Exception  
                          MessageBox.Show(ex.Message,   "Error!!",   MessageBoxButtons.OK,   MessageBoxIcon.Error)  
                          Exit   Sub  
                  End   Try  
          End   Sub  
  End   ClassTop

5 楼xiangzhong(刀含梦)回复于 2006-03-02 22:36:30 得分 0

Public   Class   class1  
                  '声明函数  
                  Declare   Auto   Function   DRV_DioWriteBit   Lib   "adsapi32.dll"   _  
                            (ByVal   DriverHandle   As   Long,     ByVal   DioWriteBit   As   PT_DioWriteBit)   As   Integer  
          End   Class  
   
  这里面的   ByVal   DioWriteBit   As   PT_DioWriteBit   应是:ByRef   DioWriteBit   As   PT_DioWriteBit,,错误不变Top

6 楼zhouxiaotan(夜雨悠扬)回复于 2006-03-02 22:48:27 得分 0

给结构体的所有属性加上get和set方法试一下阿Top

7 楼xiangzhong(刀含梦)回复于 2006-03-03 08:39:02 得分 0

无济于事,,恳请遇到过类似问题的大侠帮我解答,谢谢Top

8 楼xiangzhong(刀含梦)回复于 2006-03-03 09:13:51 得分 0

ok,,自己解决了,庆祝下Top

相关问题

  • 问!!!
  • 问!
  • 问::
  • 问:
  • 问!
  • 问?????
  • 问!!!!!!!
  • 问?
  • 问!!!!!!!!!!
  • 问

关键词

  • 函数
  • dll
  • diowritebit
  • ptdiowritebit
  • drv
  • newclass
  • byval
  • pt
  • 错误
  • 时候

得分解答快速导航

  • 帖主:xiangzhong

相关链接

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

广告也精彩

反馈

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