由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - a question about C++.net class library
相关主题
修改.dll文件how to import C# .net DLL in VC6?
How to make Internet Explorer Toolbar?怎么写多语言的程序?
How to use openFileDialog() to save a binary file in .net C++how to use old DLL in VB .NET?
混合语言编程[solved] Re: use old DLL in VB .NET?
CE.Net 4.2 questionCrystalReport 问题
understand ASP .Net 2: ASP .Net vs ATL Server如何注销一个顽固留在内存的DLL?
Re: DotNetNuke2.04, Could you pls expla求教:从条形码扫描器Scanner读数据到VB .NET程序
用DLL会快些吗?问个弱问题
相关话题的讨论汇总
话题: sbyte话题: c#话题: c++话题: net话题: filename
进入DotNet版参与讨论
1 (共1页)
w**w
发帖数: 5391
1
in .NET, i defined a function in C++ class library for file open
int open(char* filename) {blah...}
Now i want to use it in C#, add reference from this DLL. C# asks:
open(sbyte*)
how to use this function in C#, where to convert a string to sbyte* ?
thanks.
y****t
发帖数: 10233
2
it is not safe code, i think.

【在 w**w 的大作中提到】
: in .NET, i defined a function in C++ class library for file open
: int open(char* filename) {blah...}
: Now i want to use it in C#, add reference from this DLL. C# asks:
: open(sbyte*)
: how to use this function in C#, where to convert a string to sbyte* ?
: thanks.

w**w
发帖数: 5391
3
the problem is how to convert it. it is impossible for everyone to rewrite the
previous code, i suppose .NET should be able to handle it.

【在 y****t 的大作中提到】
: it is not safe code, i think.
s*i
发帖数: 5025
4
try this:
//in C#, make a sbyte array, say
//sbyte[] sArray = .....
unsafe
{
fixed(byte *fileName=sArray) className.open(fileName);
}
This should work. Remember to enable 'unsafe blocks" in Visual Studio to
compile correctly.
Working with sbyte is actually not very convinient. If you can recompile your
C++ with "/J" (default char unsigned: Yes), your expected input becomes
"byte*" instead of "sbyte*". This way, you can try this:
//using System.Text
.....
ASCIIEncoding encoding=new ASCIIEncod

【在 w**w 的大作中提到】
: in .NET, i defined a function in C++ class library for file open
: int open(char* filename) {blah...}
: Now i want to use it in C#, add reference from this DLL. C# asks:
: open(sbyte*)
: how to use this function in C#, where to convert a string to sbyte* ?
: thanks.

w**w
发帖数: 5391
5
thanks a lot!! The second method works. I had troubles to convert sbyte, so i
didn't try first one, but it looks fine as well.

【在 s*i 的大作中提到】
: try this:
: //in C#, make a sbyte array, say
: //sbyte[] sArray = .....
: unsafe
: {
: fixed(byte *fileName=sArray) className.open(fileName);
: }
: This should work. Remember to enable 'unsafe blocks" in Visual Studio to
: compile correctly.
: Working with sbyte is actually not very convinient. If you can recompile your

1 (共1页)
进入DotNet版参与讨论
相关主题
问个弱问题CE.Net 4.2 question
[合集] 问一个Response.WriteFile的问题understand ASP .Net 2: ASP .Net vs ATL Server
C#的new在method declaration里有和没有有啥区别么Re: DotNetNuke2.04, Could you pls expla
包子题: Implement GetFullPathOfIsolatedFile用DLL会快些吗?
修改.dll文件how to import C# .net DLL in VC6?
How to make Internet Explorer Toolbar?怎么写多语言的程序?
How to use openFileDialog() to save a binary file in .net C++how to use old DLL in VB .NET?
混合语言编程[solved] Re: use old DLL in VB .NET?
相关话题的讨论汇总
话题: sbyte话题: c#话题: c++话题: net话题: filename