c dll到c# [英] c dll to c#

查看:58
本文介绍了c dll到c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

我有一个.dll,我想从c#来源打电话。但是我不能想出一个

的方式...

这是.dll的输入变量和定义。

externC void _stdcall MyFunc(unsigned char var1 [100],int length,

unsigned long * arrFinal)


我想通过[DllImport(路径)来调用它,EntryPoint = MyFunc)]

public static extern void MyFunc(这里是变量)


但我无法弄清楚unsigned char和unsigned long的替换

* c#中的类型。


你能帮助我吗?谢谢。

Hi everyone.
I have a .dll that i want to call from a c# source. But i can''t figure out a
way...
Here are the .dll''s input variables and the definition.

extern "C" void _stdcall MyFunc(unsigned char var1[100], int length,
unsigned long *arrFinal)

And I want to call it by [DllImport(path,EntryPoint=MyFunc)]
public static extern void MyFunc(here comes the variables)

but i cannot figure out the replacements for unsigned char and unsigned long
* types in c#.

Can you help me? Thanks.

推荐答案

您好,


尝试将System.Byte [100]用于unsigned char [ 100]和System.UInt64 for

unsigned long。


Mihaly


" Arda Zuber"写道:
Hello,

Try to use System.Byte[100] for unsigned char[100] and System.UInt64 for
unsigned long.

Mihaly

"Arda Zuber" wrote:
大家好。
我有一个.dll,我想从c#源代码调用。但是我不能想出一个
方式......
这里是.dll'的输入变量和定义。

externC void _stdcall MyFunc(unsigned char var1 [100],int length,
unsigned long * arrFinal)

我想通过[DllImport(path,EntryPoint = MyFunc)]来调用它/> public static extern void MyFunc(这里是变量)

但我无法弄清楚c#中unsigned char和unsigned long
*类型的替换。

>你能帮帮我吗?谢谢。
Hi everyone.
I have a .dll that i want to call from a c# source. But i can''t figure out a
way...
Here are the .dll''s input variables and the definition.

extern "C" void _stdcall MyFunc(unsigned char var1[100], int length,
unsigned long *arrFinal)

And I want to call it by [DllImport(path,EntryPoint=MyFunc)]
public static extern void MyFunc(here comes the variables)

but i cannot figure out the replacements for unsigned char and unsigned long
* types in c#.

Can you help me? Thanks.



根本没有,UInt64是64位,C长是32位!


威利。


Mihaly <弥**** @ discussions.microsoft.com>在消息中写道

news:17 ********************************** @ microsof t.com ...

|您好,

|

|尝试将System.Byte [100]用于unsigned char [100]和System.UInt64 for

| unsigned long。

|

| Mihaly

|

| Arda Zuber写道:

|

| >大家好。

| >我有一个.dll,我想从c#源代码调用。但我无法想象

出一个

| >方式...

| >这是.dll的输入变量和定义。

| >

| >外部C void _stdcall MyFunc(unsigned char var1 [100],int length,

|> unsigned long * arrFinal)

| >

| >我想通过[DllImport(路径,EntryPoint = MyFunc)]来调用它

| > public static extern void MyFunc(这里是变量)

| >

| >但我无法弄清楚unsigned char和unsigned的替换



| > * c#中的类型。

| >

| >你能帮助我吗?谢谢。
Not at all, UInt64 is 64 bit, a long in C is 32 bit!

Willy.

"Mihaly" <Mi****@discussions.microsoft.com> wrote in message
news:17**********************************@microsof t.com...
| Hello,
|
| Try to use System.Byte[100] for unsigned char[100] and System.UInt64 for
| unsigned long.
|
| Mihaly
|
| "Arda Zuber" wrote:
|
| > Hi everyone.
| > I have a .dll that i want to call from a c# source. But i can''t figure
out a
| > way...
| > Here are the .dll''s input variables and the definition.
| >
| > extern "C" void _stdcall MyFunc(unsigned char var1[100], int length,
| > unsigned long *arrFinal)
| >
| > And I want to call it by [DllImport(path,EntryPoint=MyFunc)]
| > public static extern void MyFunc(here comes the variables)
| >
| > but i cannot figure out the replacements for unsigned char and unsigned
long
| > * types in c#.
| >
| > Can you help me? Thanks.


取决于。


int的大小定义为CPU的字大小。很长的是

只定义为至少一个int的大小。


Willy Denoyette [MVP]写道:
That depends.

The size of an int is defined as the word size of the CPU. A long is
only defined to be at least the size of an int.

Willy Denoyette [MVP] wrote:
根本没有,UInt64是64位,C长是32位!

Willy。

Mihaly <弥**** @ discussions.microsoft.com>在消息中写道
新闻:17 ********************************** @ microsof t.com。 ..
|您好,
|
|尝试将System.Byte [100]用于unsigned char [100],将System.UInt64用于
|无条件的长。
|
| Mihaly
|
| Arda Zuber写道:
|
| >大家好。
| >我有一个.dll,我想从c#源代码调用。但我无法想象
|
>方式......
| >这是.dll的输入变量和定义。
| >
| >外部C void _stdcall MyFunc(unsigned char var1 [100],int length,
|> unsigned long * arrFinal)
| >
| >我想通过[DllImport(path,EntryPoint = MyFunc)]
|来调用它> public static extern void MyFunc(这里是变量)
| >
| >但我无法弄清楚无符号字符和未签名字符的替换长期
| > * c#中的类型。
| >
| >你能帮助我吗?谢谢。
Not at all, UInt64 is 64 bit, a long in C is 32 bit!

Willy.

"Mihaly" <Mi****@discussions.microsoft.com> wrote in message
news:17**********************************@microsof t.com...
| Hello,
|
| Try to use System.Byte[100] for unsigned char[100] and System.UInt64 for
| unsigned long.
|
| Mihaly
|
| "Arda Zuber" wrote:
|
| > Hi everyone.
| > I have a .dll that i want to call from a c# source. But i can''t figure
out a
| > way...
| > Here are the .dll''s input variables and the definition.
| >
| > extern "C" void _stdcall MyFunc(unsigned char var1[100], int length,
| > unsigned long *arrFinal)
| >
| > And I want to call it by [DllImport(path,EntryPoint=MyFunc)]
| > public static extern void MyFunc(here comes the variables)
| >
| > but i cannot figure out the replacements for unsigned char and unsigned
long
| > * types in c#.
| >
| > Can you help me? Thanks.



这篇关于c dll到c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆