您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> .NET >> 如何通过MarshalGetFunctionPointerForDelegate获取函数指针?

如何通过MarshalGetFunctionPointerForDelegate获取函数指针?

来源:网络整理     时间:2016/6/18 8:36:12     关键词:

关于网友提出的“ 如何通过MarshalGetFunctionPointerForDelegate获取函数指针?”问题疑问,本网通过在网上对“ 如何通过MarshalGetFunctionPointerForDelegate获取函数指针?”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 如何通过MarshalGetFunctionPointerForDelegate获取函数指针?
描述:

     工作中遇到这样一个问题,需要在c#托管代码中,调用函数指针。我在类中添加了一个自定义方法makerClick和一个委托ClickDeleage。
     public delegate bool ClickDeleage();//单击标注委托对象
     public  bool makerClick()  //单击标准事件
        {
            string currPosdes = ""; //当前位置兴趣点描述
            MLonLat currMakerLonlat = new MLonLat();
            currMakerLonlat.fLon = float.Parse(currPosition.Longitude.ToString());
            currMakerLonlat.fLat = float.Parse(currMakerLonlat.fLat.ToString());
            MREGEOCODESEARCHOPTIONS Option = new MREGEOCODESEARCHOPTIONS();
            MReGeocodeSearchResult result = this.mapCtrl1.HttpPoiToAddress(currMakerLonlat, Option);
            if (result == null)
            {
                currPosdes = ""; //为获取到该位置附近的兴趣点信息。
            }
            if (result.lNumOfRoundPoi == 1)
            {
                currPosdes = result.pRoundPois[0].cName;
            }
            if (result.lNumOfRoundPoi > 1)
            {
                currPosdes = nearestFind(result.pRoundPois, FromGpsToLonlat(currPosition)).cName;
            }
            StringBuilder makerText = new StringBuilder();
            makerText.Append("当前经度:" + currPosition.Longitude.ToString());
            makerText.Append("当前纬度:" + currPosition.Latitude.ToString());
            makerText.Append("当前位置信息:" + currPosdes);
            notification1.Caption = "当前位置信息";
            notification1.Visible = true;
            notification1.Text = makerText.ToString();
            return true;
        }
   通过上边的委托和函数来获取指针,以下是我获取函数指针的过程:
      makerClickdelegate mydelegate=new makerClickdelegate(makerClick);
      IntPtr functionPointer = Marshal.GetFunctionPointerForDelegate(mydelegate);
  可这样确报了一个NotSupportedException的错误,目标平台是mobile5.大家帮忙看看,谢谢。
      


解决方案1:

兄弟我也问题和你类似啊?
有人知道帮我也看看那
http://topic.csdn.net/u/20110215/17/10b4584b-17ef-4e6d-90ae-2f3b1eb15174.html

解决方案2:

已经沉了。。。。。。。 如何通过MarshalGetFunctionPointerForDelegate获取函数指针?


以上介绍了“ 如何通过MarshalGetFunctionPointerForDelegate获取函数指针?”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1749479.html

相关图片

相关文章