473,324 Members | 2,531 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,324 software developers and data experts.

Vb6 Convert

Hi
Can you help me with converting a VB6 Declare Function construct to C#
systax. I think it is in the form of

[DLLImport ("A.DLL")]
public extrn void someFunction(.....);

But I don't see the association between the 2 statements. Can someone
explain ?

THanks
Nov 5 '08 #1
4 1454
Phil,

Well, the DllImport attribute tells the CLR what the name of the DLL is
to load to find the function in (as well as other information, like the .
The CLR will then use function information to figure out the signature of
the function and load it from the dll, and subsequently call it.

The "extern" keyword here, combined with the attribute indicates that
the function is found in an unmanaged DLL (there should be a static keyword
here as well).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil Hunt" <aa*@aaa.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi
Can you help me with converting a VB6 Declare Function construct to C#
systax. I think it is in the form of

[DLLImport ("A.DLL")]
public extrn void someFunction(.....);

But I don't see the association between the 2 statements. Can someone
explain ?

THanks

Nov 5 '08 #2
The dll i have that has many entry point. It seems like I have to repeat the
Import statement everytime I declare a different function. Is that a short
hand for that. Also in VB6 the Declare stmt associate the fucntion with the
dll. Can I do that in this contruct ?

Thanks again
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:OU**************@TK2MSFTNGP02.phx.gbl...
Phil,

Well, the DllImport attribute tells the CLR what the name of the DLL is
to load to find the function in (as well as other information, like the .
The CLR will then use function information to figure out the signature of
the function and load it from the dll, and subsequently call it.

The "extern" keyword here, combined with the attribute indicates that
the function is found in an unmanaged DLL (there should be a static
keyword here as well).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil Hunt" <aa*@aaa.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Hi
Can you help me with converting a VB6 Declare Function construct to C#
systax. I think it is in the form of

[DLLImport ("A.DLL")]
public extrn void someFunction(.....);

But I don't see the association between the 2 statements. Can someone
explain ?

THanks


Nov 5 '08 #3
Phil,

Yes, you are right, you have to make a new declaration for each function
that you want to use through the P/Invoke layer.

There is no shorthand for that, AFAIK.

The DllImport attribute is what associates the function declaration with
the DLL that it is located in. You have to repeat this for every
declaration as well.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil Hunt" <aa*@aaa.comwrote in message
news:eH**************@TK2MSFTNGP02.phx.gbl...
The dll i have that has many entry point. It seems like I have to repeat
the Import statement everytime I declare a different function. Is that a
short hand for that. Also in VB6 the Declare stmt associate the fucntion
with the dll. Can I do that in this contruct ?

Thanks again
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:OU**************@TK2MSFTNGP02.phx.gbl...
>Phil,

Well, the DllImport attribute tells the CLR what the name of the DLL
is to load to find the function in (as well as other information, like
the . The CLR will then use function information to figure out the
signature of the function and load it from the dll, and subsequently call
it.

The "extern" keyword here, combined with the attribute indicates that
the function is found in an unmanaged DLL (there should be a static
keyword here as well).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil Hunt" <aa*@aaa.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>Hi
Can you help me with converting a VB6 Declare Function construct to C#
systax. I think it is in the form of

[DLLImport ("A.DLL")]
public extrn void someFunction(.....);

But I don't see the association between the 2 statements. Can someone
explain ?

THanks



Nov 5 '08 #4
Thanks for your help.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:ud**************@TK2MSFTNGP04.phx.gbl...
Phil,

Yes, you are right, you have to make a new declaration for each
function that you want to use through the P/Invoke layer.

There is no shorthand for that, AFAIK.

The DllImport attribute is what associates the function declaration
with the DLL that it is located in. You have to repeat this for every
declaration as well.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil Hunt" <aa*@aaa.comwrote in message
news:eH**************@TK2MSFTNGP02.phx.gbl...
>The dll i have that has many entry point. It seems like I have to repeat
the Import statement everytime I declare a different function. Is that a
short hand for that. Also in VB6 the Declare stmt associate the fucntion
with the dll. Can I do that in this contruct ?

Thanks again
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:OU**************@TK2MSFTNGP02.phx.gbl...
>>Phil,

Well, the DllImport attribute tells the CLR what the name of the DLL
is to load to find the function in (as well as other information, like
the . The CLR will then use function information to figure out the
signature of the function and load it from the dll, and subsequently
call it.

The "extern" keyword here, combined with the attribute indicates that
the function is found in an unmanaged DLL (there should be a static
keyword here as well).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil Hunt" <aa*@aaa.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .
Hi
Can you help me with converting a VB6 Declare Function construct to C#
systax. I think it is in the form of

[DLLImport ("A.DLL")]
public extrn void someFunction(.....);

But I don't see the association between the 2 statements. Can someone
explain ?

THanks



Nov 5 '08 #5

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

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
4
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
6
by: Ken Fine | last post by:
This is a basic question. What is the difference between casting and using the Convert.ToXXX methods, from the standpoint of the compiler, in terms of performance, and in other ways? e.g. ...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.