473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Using VB.NET

Nak
Hi there,

I am trying to convert the following to VB.NET code, it is a C# wrapper
for a C++ DLL,

using PVOID = IntPtr;
using FIBITMAP = Int32;
using FIMULTIBITMAP = Int32;

As I understand it, the objects on the right are being given the aliases
on the left, so PVOID objects are actually IntPrt objects (or so I
understand anyway. How would I write this in VB.NET? I could just remove
all aliases, but I thought I would quickly ask as this one has got me.
Thanks loads.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #1
12 2160
* "Nak" <a@a.com> scripsit:
I am trying to convert the following to VB.NET code, it is a C# wrapper
for a C++ DLL,

using PVOID = IntPtr;
using FIBITMAP = Int32;
using FIMULTIBITMAP = Int32;

As I understand it, the objects on the right are being given the aliases
on the left, so PVOID objects are actually IntPrt objects (or so I
understand anyway. How would I write this in VB.NET?


Something like 'Imports PVIOD = System.IntPtr' (untested)?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
I would expect that these are types in the C++ dl. Since these types do not
exist in VB.Net they need to be replaced.
Therefore, a function such as:
\\\
<DllImport("MyLib")> _
Private Shared Function MyUnknownFunction ( _
ByVal Arg1 as PVOID, _
ByVal Arg2 As FIBITMAP) As
FIMULTIBITMAP
End Function
///
would translate to:
\\\
<DllImport("MyLib")> _
Private Shared Function MyUnknownFunction ( _
ByVal Arg1 as Intptr, _
ByVal Arg2 As Int32) As Int32
End Function
///
allowing VB.Net to understand the Types Passed.

I may be wrong, but that makes sense to me.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bn************@ID-208219.news.uni-berlin.de...
* "Nak" <a@a.com> scripsit:
I am trying to convert the following to VB.NET code, it is a C# wrapper
for a C++ DLL,

using PVOID = IntPtr;
using FIBITMAP = Int32;
using FIMULTIBITMAP = Int32;

As I understand it, the objects on the right are being given the aliases
on the left, so PVOID objects are actually IntPrt objects (or so I
understand anyway. How would I write this in VB.NET?


Something like 'Imports PVIOD = System.IntPtr' (untested)?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
Nak
Hi Herfried,
Something like 'Imports PVIOD = System.IntPtr' (untested)?


Unfortunately it doesn't find it, I'm getting the error message,

"Namespace or type 'IntPtr' for the imports 'IntPrt' cannot be found.

It looks like I may have to replace everything instead, which is a bugger!
Oh well :-(

Nick.
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #4
Nak
Hi Mick,
I would expect that these are types in the C++ dl. Since these types do not exist in VB.Net they need to be replaced.


I understand what you are saying but the actual lines I am trying to find VB
replacements for simply give a type an alias. Such as

Using pastrami = Int;

pastrami badger = 50;

^ In essence this declares an integer with a value of 50.

I've started simply removing the alias's now, which could cause confusion at
a later date, I shall see :-\

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #5
Hi Nick, Herfried,
Did you get the spelling right - I notice both 'IntPtr' and 'IntPrt' in
your post?

I tried it and it worked fine.

Imports PVOID = System.IntPtr
Dim ThisPVoid As PVOID = PVOID.Zero
S$ = ThisPVoid.ToInt64.ToString

Can't do a lot with it mind - just set it to zero and pass it around. But
that's enough, I gather.

Regards,
Fergus

Nov 20 '05 #6
* "Nak" <a@a.com> scripsit:
Something like 'Imports PVIOD = System.IntPtr' (untested)?


Unfortunately it doesn't find it, I'm getting the error message,

"Namespace or type 'IntPtr' for the imports 'IntPrt' cannot be found.

It looks like I may have to replace everything instead, which is a bugger!
Oh well :-(


Are you sure you typed the fully qualified name ('System.IntPtr' instead
of 'IntPtr'? This works for me on .NET 1.1.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #7
Nick,
Herfried's suggestion should work, I'm not sure why you would get an error.

Are you on VS.NET 2002 or VS.NET 2003, the following works in VS.NET 2003.

Option Strict On
Option Explicit On

Imports PVOID = System.IntPtr
Imports FIBITMAP = System.Int32
Imports FIMULTIBITMAP = System.Int32
<DllImport("MyLib")> _
Private Shared Function MyUnknownFunction ( _
ByVal Arg1 as PVOID, _
ByVal Arg2 As FIBITMAP) _
As FIMULTIBITMAP

Note you need the fully qualified name on the import, System.Int32, not just
Int32.

Just remember that you are defining an Alias, not a new type when you use
the Imports Alias.

Hope this helps
Jay

"Nak" <a@a.com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
Hi Mick,
I would expect that these are types in the C++ dl. Since these types do not
exist in VB.Net they need to be replaced.


I understand what you are saying but the actual lines I am trying to find

VB replacements for simply give a type an alias. Such as

Using pastrami = Int;

pastrami badger = 50;

^ In essence this declares an integer with a value of 50.

I've started simply removing the alias's now, which could cause confusion at a later date, I shall see :-\

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ "No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Nov 20 '05 #8
* "Fergus Cooney" <fi*****@post.com> scripsit:
Did you get the spelling right - I notice both 'IntPtr' and 'IntPrt' in
your post?

I tried it and it worked fine.

Imports PVOID = System.IntPtr
Dim ThisPVoid As PVOID = PVOID.Zero
S$ = ThisPVoid.ToInt64.ToString
I prefer:

\\\
Dim s As String = ThisPVoid.ToInt64().ToString()
///

;-)
Can't do a lot with it mind - just set it to zero and pass it around. But
that's enough, I gather.


Works fine for me too.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #9
Nak
Hi there,

AAaaah I needed the system part! (System.IntPtr), I thought it would
find it regardless, woops :-) Thanks

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #10
Nak
Hi Herfried,
Are you sure you typed the fully qualified name ('System.IntPtr' instead
of 'IntPtr'? This works for me on .NET 1.1.


I missed out the full name, all is well now, thanks :-) I thought it might
be something I was doing wrong.

Imports pastrami = System.Int32 sorted!

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #11
Hi Nick,

And now I know that I can alias types - I wasn't aware of that before.
Should be able to confuse a couple of junior programmers with that at some
time.

Keep up with the questions, Nick, I'm learning about remoting and
security, obfuscalating and everything.
pastrami badger = 50

ROFL

badger.beatwith (GetType (badger))

Regarts,
Fergus
Nov 20 '05 #12
Nak
Hi Fergus,
Keep up with the questions, Nick, I'm learning about remoting and
security, obfuscalating and everything.
I've got a lovely remote server in development at the moment which requires
login and such like, all of this to access my database files via a proxy for
increased security!
badger.beatwith (GetType (badger))
ROFL, could a badger be type casted to a "stoutStick"?

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Nov 20 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
3
by: Mike L | last post by:
Should the command call "using" be before or after my namespace? **AFTER** namespace DataGridBrowser { using System; using System.Drawing; using System.Drawing.Drawing2D; using...
3
by: xzzy | last post by:
I was wondering why we have to have using System.Data using System.Configuration using etc.... why are they not all lumped into one 'using'? In other words, is there a best way to use...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
8
by: acb | last post by:
Hi, I wrote a DLL Component (using Visual Studio 2005) and managed to include it into a C# Console application. I am now trying to include this component into a Web project. I copy the DLL...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
10
by: mg | last post by:
I'm migrating from VB6 and have a question about using 'Using' and the best way to use it. Here is a example of a small bit of code: dbConx("open") Using CN Dim CMD As New OleDbCommand(sSQL,...
0
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.