![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||