VB.NET和eVC ++之间的互操作 [英] interop between VB.NET and eVC++

查看:72
本文介绍了VB.NET和eVC ++之间的互操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那里,


我正在开发一个关于VB.NET的智能应用程序项目。我必须调用API

(自定义eVC ++ DLL)但我在使用mashalas属性时遇到了一些问题.....

i在msdn帮助上复制/过去样本但是它'不工作..

IDE说'未知''mashalAs''属性'.....我不知道为什么......

i在普通的Windows项目中尝试完全相同的代码并且它可以工作

(编译)很好......


i不要知道我错过了什么....


这里有一些我的代码...


非常感谢...


导入System.Runtime.InteropServices


公共类Form1


公共声明函数F_BDO_MessageBoxOK Lib " PDA_BDO.dll" (ByRef

IN_title()As Byte,< MarshalAs(UnmanagedType.LPStr)> ByRef IN_msg As String)

As Int32

hi there,

i''m working on a smart application project on VB.NET. i must call API
(custom eVC++ DLL) but i have some trouble with mashalas attribute.....
i have copy/past a sample on msdn help but it''s not working..
IDE says "unknown ''mashalAs'' attribute".....and i don''t know why....

i have try exactly the same code on a normal windows project and it work
(compile) fine...

i don''t know what i''ve missed....

here some lines of my code...

thank a lot...

Imports System.Runtime.InteropServices

Public Class Form1

Public Declare Function F_BDO_MessageBoxOK Lib "PDA_BDO.dll" (ByRef
IN_title() As Byte, <MarshalAs(UnmanagedType.LPStr)> ByRef IN_msg As String)
As Int32

推荐答案

CF中不支持MarshalAs属性 - 只需删除它,你的字符串

将作为LPCWSTR传递(注意常量部分)

至于字节数组,用ByVal替换ByRef - 数组将通过

降低为LPBYTE


-

Alex Feinman

---

访问 http://www.opennetcf.org

" Eric BOUXIROT" < RI **** @ rickou.net>在消息中写道

news:41 ********************** @ news.free.fr ...
MarshalAs attribute is not supported in CF - simply drop it, and your string
will be passed as LPCWSTR (note the constant part)
As for a byte array, replace ByRef with ByVal - the array will be passed
down as LPBYTE

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Eric BOUXIROT" <ri****@rickou.net> wrote in message
news:41**********************@news.free.fr...
那里,

我正在研究VB.NET上的智能应用程序项目。我必须调用API
(自定义eVC ++ DLL),但我对mashalas属性有一些麻烦.....
我已经在msdn帮助上复制/过去了一个样本但是它没有工作.. < IDE说未知'mashalAs''属性'.....我不知道为什么......

我在正常情况下尝试完全相同的代码windows项目和它工作
(编译)很好......

我不知道我错过了什么....

这里有些我的代码行...

非常感谢...

Imports System.Runtime.InteropServices

Public Class Form1

公共声明函数F_BDO_MessageBoxOK LibPDA_BDO.dll (ByRef
IN_title()As Byte,< MarshalAs(UnmanagedType.LPStr)> ByRef IN_msg As
String)As Int32
hi there,

i''m working on a smart application project on VB.NET. i must call API
(custom eVC++ DLL) but i have some trouble with mashalas attribute.....
i have copy/past a sample on msdn help but it''s not working..
IDE says "unknown ''mashalAs'' attribute".....and i don''t know why....

i have try exactly the same code on a normal windows project and it work
(compile) fine...

i don''t know what i''ve missed....

here some lines of my code...

thank a lot...

Imports System.Runtime.InteropServices

Public Class Form1

Public Declare Function F_BDO_MessageBoxOK Lib "PDA_BDO.dll" (ByRef
IN_title() As Byte, <MarshalAs(UnmanagedType.LPStr)> ByRef IN_msg As
String) As Int32



哦确定.....


谢谢,但我还有一个问题......

在我的eVC ++ DLL中有些功能使用非unicode字符串(unsigned char *)


如何告诉VB用非UNICODE字符串格式调用DLL?


谢谢很多!

" Alex Feinman [MVP]" < PU ********* @ alexfeinman.com> écritdansle message

de news: uH *** ***********@TK2MSFTNGP09.phx.gbl ...
oh ok.....

thank, but i have one more question...
in my eVC++ DLL some functions use non-unicode strings (unsigned char*)

how i can tell VB to call DLL with non-UNICODE string format ?

thank a lot !
"Alex Feinman [MVP]" <pu*********@alexfeinman.com> a écrit dans le message
de news: uH**************@TK2MSFTNGP09.phx.gbl...
CF不支持MarshalAs属性 - 只需删除它,然后你的
字符串将作为LPCWSTR传递(注意常量部分)
至于字节数组,用ByVal替换ByRef - 数组将作为LPBYTE传递

- < Alex Feinman
---
访问 http://www.opennetcf .org
Eric BOUXIROT < RI **** @ rickou.net>在消息中写道
新闻:41 ********************** @ news.free.fr ...
MarshalAs attribute is not supported in CF - simply drop it, and your
string will be passed as LPCWSTR (note the constant part)
As for a byte array, replace ByRef with ByVal - the array will be passed
down as LPBYTE

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Eric BOUXIROT" <ri****@rickou.net> wrote in message
news:41**********************@news.free.fr...
hi那里,我正在开发一个关于VB.NET的智能应用程序项目。我必须调用API
(自定义eVC ++ DLL),但我对mashalas属性有一些麻烦.....
我已经在msdn帮助上复制/过去了一个样本但是它没有工作.. < IDE说未知'mashalAs''属性'.....我不知道为什么......

我在正常情况下尝试完全相同的代码windows项目和它工作
(编译)很好......

我不知道我错过了什么....

这里有些我的代码行...

非常感谢...

Imports System.Runtime.InteropServices

Public Class Form1

公共声明函数F_BDO_MessageBoxOK LibPDA_BDO.dll (ByRef
IN_title()As Byte,< MarshalAs(UnmanagedType.LPStr)> ByRef IN_msg As
String)As Int32
hi there,

i''m working on a smart application project on VB.NET. i must call API
(custom eVC++ DLL) but i have some trouble with mashalas attribute.....
i have copy/past a sample on msdn help but it''s not working..
IDE says "unknown ''mashalAs'' attribute".....and i don''t know why....

i have try exactly the same code on a normal windows project and it work
(compile) fine...

i don''t know what i''ve missed....

here some lines of my code...

thank a lot...

Imports System.Runtime.InteropServices

Public Class Form1

Public Declare Function F_BDO_MessageBoxOK Lib "PDA_BDO.dll" (ByRef
IN_title() As Byte, <MarshalAs(UnmanagedType.LPStr)> ByRef IN_msg As
String) As Int32




传递一个字节数组。


-Chris

" Eric BOUXIROT" < RI **** @ rickou.net>在消息中写道

news:41 ********************** @ news.free.fr ...
Pass a byte array.

-Chris
"Eric BOUXIROT" <ri****@rickou.net> wrote in message
news:41**********************@news.free.fr...
哦确定.....

谢谢,但我还有一个问题...
在我的eVC ++ DLL中,一些函数使用非unicode字符串(unsigned char *)

我怎么能告诉VB用非UNICODE字符串格式调用DLL?

非常感谢!

" Alex Feinman [MVP]" ; < PU ********* @ alexfeinman.com> écritdansle message
de news: uH ******* *******@TK2MSFTNGP09.phx.gbl ...
oh ok.....

thank, but i have one more question...
in my eVC++ DLL some functions use non-unicode strings (unsigned char*)

how i can tell VB to call DLL with non-UNICODE string format ?

thank a lot !
"Alex Feinman [MVP]" <pu*********@alexfeinman.com> a écrit dans le message
de news: uH**************@TK2MSFTNGP09.phx.gbl...
CF不支持MarshalAs属性 - 只需删除它,你的
字符串将被传递作为LPCWSTR(注意常量部分)
至于字节数组,用ByVal替换ByRef - 数组将作为LPBYTE传递


- Alex Feinman
---
访问 http://www.opennetcf.org
Eric BOUXIROT < RI **** @ rickou.net>在消息中写道
新闻:41 ********************** @ news.free.fr ...
MarshalAs attribute is not supported in CF - simply drop it, and your
string will be passed as LPCWSTR (note the constant part)
As for a byte array, replace ByRef with ByVal - the array will be passed
down as LPBYTE

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Eric BOUXIROT" <ri****@rickou.net> wrote in message
news:41**********************@news.free.fr...
hi那里,我正在开发一个关于VB.NET的智能应用程序项目。我必须调用API
(自定义eVC ++ DLL),但我对mashalas属性有一些麻烦.....
我已经在msdn帮助上复制/过去了一个样本但是它没有工作.. < IDE说未知'mashalAs''属性'.....我不知道为什么......

我在正常情况下尝试完全相同的代码windows项目和
工作(编译)很好......

我不知道我错过了什么....

这里有些我的代码行...

非常感谢...

Imports System.Runtime.InteropServices

Public Class Form1

公共声明函数F_BDO_MessageBoxOK LibPDA_BDO.dll (ByRef
IN_title()As Byte,< MarshalAs(UnmanagedType.LPStr)> ByRef IN_msg As
String)As Int32
hi there,

i''m working on a smart application project on VB.NET. i must call API
(custom eVC++ DLL) but i have some trouble with mashalas attribute.....
i have copy/past a sample on msdn help but it''s not working..
IDE says "unknown ''mashalAs'' attribute".....and i don''t know why....

i have try exactly the same code on a normal windows project and it work (compile) fine...

i don''t know what i''ve missed....

here some lines of my code...

thank a lot...

Imports System.Runtime.InteropServices

Public Class Form1

Public Declare Function F_BDO_MessageBoxOK Lib "PDA_BDO.dll" (ByRef
IN_title() As Byte, <MarshalAs(UnmanagedType.LPStr)> ByRef IN_msg As
String) As Int32





这篇关于VB.NET和eVC ++之间的互操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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