C#将String传入C++的char*
C++的函数参数列表中包含一个char*的输出型参数,然而在C#调用该dll时候,会自动将函数的中的char*参数“翻译”为sbyte*, 使用了各种方法都不能调用函数,主要是不能合适的转换为sbyte*。
1、【项目】->【属性】->【生成】->勾选 【允许不安全代码】
2、引入头文件 using System.Runtime.InteropServices;
3、
string videoName = "ComplexBkg1.avi";
unsafe {
IntPtr intPtrStr = (IntPtr)Marshal.StringToHGlobalAnsi(videoName);
sbyte* sbyteStr = (sbyte*)intPtrStr;
temp.fishTracking(sbyteStr);
}
C#将String传入C++的char*的更多相关文章
- C++字符串【string】和【char []】操作全攻略
异想之旅:本人博客完全手敲,绝对非搬运,全网不可能有重复:本人无团队,仅为技术爱好者进行分享,所有内容不牵扯广告.本人所有文章发布平台为CSDN.博客园.简书和开源中国,后期可能会有个人博客,除此之外 ...
- c++ 中double与string之间的转换,char *
运行代码为 /* * main.cpp * * Created on: Apr 7, 2016 * Author: lizhen */ #include <iostream> //#inc ...
- String底层使用是char数组还是byte数组
结论:jdk1.8及以前String底层使用是char[],1.9开始使用byte[] jdk1.8 jdk13
- Delphi中的各种字符串、String、PChar、Char数组
参考博客:http://www.cnblogs.com/pchmonster/archive/2011/12/14/2287686.html 其中的所有代码均在Delphi7下测试通过. Delphi ...
- Java的string学习笔记 与char数组和bufferstring的比较
---恢复内容开始--- 一直用的C 导致这种类望而生畏 现在终于鼓起勇气学习一下 首先学习string类型 String s1 = "AbCdEf"; String s2 = & ...
- C++ string long double转char*
long long q = 10; ]; char* output; sprintf(s, "%ld", q); output = s; double ]; sprintf(s1, ...
- warning:deprecated conversion from string constant to 'char *'
warning:deprecated conversion from string constant to 'char *' 解决方式 #include <iostream> using ...
- java中switch的用法以及判断的类型有哪些(String\byte\short\int\char\枚举类型)
switch关键字对于多数java学习者来说并不陌生,由于笔试和面试经常会问到它的用法,这里做了一个简单的总结: 能用于switch判断的类型有:byte.short.int.char(JDK1.6) ...
- c# 调用 C++ dll 传入传出 字符串
c# 调用 C++ dll 传入传出 字符串 2013-07-02 09:30 7898人阅读 评论(2) 收藏 举报 本文章已收录于: 分类: windows 版权声明:随便转载,随便使用. C ...
随机推荐
- jquery多组图片层次切换的焦点图
效果:
- 【asp.net mvc】 扩展 htmlhelper 实现分页
参考文档:http://www.cnblogs.com/caofangsheng/p/5670071.html http://www.cnblogs.com/arte ...
- jquery 条形码 插件jquery-barcode使用
转载文章 jquery 条形码 插件jquery-barcode使用 条码官网: http://barcode-coder.com/en/barcode-jquery-plugin-201.htm ...
- Codeforces Round #380 (Div. 2)/729D Sea Battle 思维题
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the ...
- [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper
洛谷题目链接:[USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper 题目描述 A little known fact about Bessie and friends is ...
- 元类编程-- __new__和__init__的区别
class User: def __new__(cls, *args, **kwargs): print (" in new ") return super().__new__(c ...
- 最简单的图文教程,几步完成Git的公私钥配置
操作的前提是,你有git账号,并且在自己的电脑上已经装好了TorToiseGit工具.下面开始简单的教程: 第一步:Windows-->所有程序-->TortoiseGit-->Pu ...
- 【Codeforces629C】Famil Door and Brackets [DP]
Famil Door and Brackets Time Limit: 20 Sec Memory Limit: 512 MB Description Input Output Sample Inp ...
- 【BZOJ4517】【SDOI2016】排列计数 [数论]
排列计数 Time Limit: 60 Sec Memory Limit: 128 MB[Submit][Status][Discuss] Description 求有多少种长度为 n 的序列 A, ...
- 移动端页面使用rem布局
阿里团队的高清布局方案代码 所谓高清方案就是根据设备屏幕的DPR(设备像素比,又称DPPX,比如dpr=2时,表示1个CSS像素由4个物理像素点组成) 动态设置 html 的font-size, 同时 ...