venerdì 15 giugno 2012 10:50
Development Environment: Visual Studio Pro 2008, C# .Net 3.5 Windows Mobile 6.5 project
I have a Windows Mobile 6.5 project created using VS Pro 2008 and C# .Net 3.5. Because of iSafe requirements, the WM 6.5 device has 3rd party .DLL's to control the internal RFID Reader.
The 3rd party .DLL's are a mix of VB .Net (written in VS 2005) and C code. I'm concentrating on the VB .Net, as I am unfamiliar with this language and it's data structures.
I know about using DLLImport and prototyping the functions in the VB .dll's, however this is very ugly and I can't imagine doing this for 30+ functions that I need to interact with for just one .dll. FYI, there are 5 VB .dll's I need to use that have numerous functions I need to call.
Is there a cleaner way to doing this or am I simply stuck with doing it like this:
private static extern string GetVersion();
private static extern string GetFunction2(.......);
private static extern string GetFunction3(.......);
Tutte le risposte
venerdì 15 giugno 2012 11:03
When it is VB.NET library then you simply use it like you would use a C# library. There is no difference as it is .NET. Otherwise when it is an unmaged VB6 library then you can use some tools. I prefer PInvoke from redgate.
venerdì 15 giugno 2012 11:30If it is a VB6 dll, then you can reference it as any COM dll. In fact, it's not an easy task creating a VB6 dll you can p/invoke.
venerdì 15 giugno 2012 11:33
You are absolutely correct! I must've had a case of cranio-rectal infusion. I pulled in the VB .Net .dll as a reference, double-clicked and it came up in the Object viewer -- like magic.
FYI, I installed PInvoke and it never showed up in my VS Pro 2008 toolbar. Would that have something to do with the fact that I have 2008 and 2010 installed? Perhaps the installer got confused.
Thanks for the help!