Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Vb6 Convert

Reply
 
Old 11-05-2008   #1 (permalink)
Phil Hunt


 
 

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



My System SpecsSystem Spec
Old 11-05-2008   #2 (permalink)
Nicholas Paldino [.NET/C# MVP]


 
 

Re: Vb6 Convert

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]
- mvp@xxxxxx

"Phil Hunt" <aaa@xxxxxx> wrote in message
news:%23r$DHm2PJHA.4424@xxxxxx
Quote:

> 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
>

My System SpecsSystem Spec
Old 11-05-2008   #3 (permalink)
Phil Hunt


 
 

Re: Vb6 Convert

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]" <mvp@xxxxxx> wrote in
message news:OUdnZz2PJHA.3932@xxxxxx
Quote:

> 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]
> - mvp@xxxxxx
>
> "Phil Hunt" <aaa@xxxxxx> wrote in message
> news:%23r$DHm2PJHA.4424@xxxxxx
Quote:

>> 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
>>
>
>

My System SpecsSystem Spec
Old 11-05-2008   #4 (permalink)
Nicholas Paldino [.NET/C# MVP]


 
 

Re: Vb6 Convert

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]
- mvp@xxxxxx

"Phil Hunt" <aaa@xxxxxx> wrote in message
news:eHMj9O3PJHA.3932@xxxxxx
Quote:

> 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]" <mvp@xxxxxx> wrote
> in message news:OUdnZz2PJHA.3932@xxxxxx
Quote:

>> 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]
>> - mvp@xxxxxx
>>
>> "Phil Hunt" <aaa@xxxxxx> wrote in message
>> news:%23r$DHm2PJHA.4424@xxxxxx
Quote:

>>> 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
>>>
>>
>>
>
>

My System SpecsSystem Spec
Old 11-05-2008   #5 (permalink)
Phil Hunt


 
 

Re: Vb6 Convert

Thanks for your help.

"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxx> wrote in
message news:udZi6T3PJHA.4224@xxxxxx
Quote:

> 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]
> - mvp@xxxxxx
>
> "Phil Hunt" <aaa@xxxxxx> wrote in message
> news:eHMj9O3PJHA.3932@xxxxxx
Quote:

>> 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]" <mvp@xxxxxx> wrote
>> in message news:OUdnZz2PJHA.3932@xxxxxx
Quote:

>>> 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]
>>> - mvp@xxxxxx
>>>
>>> "Phil Hunt" <aaa@xxxxxx> wrote in message
>>> news:%23r$DHm2PJHA.4424@xxxxxx
>>>> 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
>>>>
>>>
>>>
>>
>>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
convert xls to pdf PowerShell
Convert .Swf to .Exe General Discussion
convert vhs to Dvd Chillout Room
RE: Convert VHD to ISO? Virtual PC
Convert EML to DBX? Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46