Using a third part DLL in VB.NET (examples in VB6)
I am considering a project based on a third party DLL. It's quite old but there is nothing else like it available. I have example code in VB6. Here's an example of how some of the DLLs functions are used in VB6:
Code:
Public Declare Function mmsGetVersion Lib "SSTVENG.DLL" () As Long
Public Declare Function mmsLanguage Lib "SSTVENG.DLL" (ByVal lang As Long) As Long
Public Declare Function mmsCreate Lib "SSTVENG.DLL" (ByVal hwnd As Long, ByVal Msg As Long) As Long
Public Declare Sub mmsDelete Lib "SSTVENG.DLL" ()
Public Declare Sub mmsStart Lib "SSTVENG.DLL" ()
Public Declare Sub mmsStop Lib "SSTVENG.DLL" ()
Public Declare Function mmsOption Lib "SSTVENG.DLL" () As Long
Public Declare Sub mmsSetOptionTitle Lib "SSTVENG.DLL" (ByVal pTitle As String)
Public Declare Function mmsSetBitmap Lib "SSTVENG.DLL" (ByVal hbRx As Long, ByVal hbSync As Long, ByVal hbTx As Long) As Long
Public Declare Function mmsSetTuneBitmap Lib "SSTVENG.DLL" (ByVal hbSpec As Long, ByVal hbWater As Long, ByVal hbLevel As Long) As Long
Public Declare Sub mmsSetHDC Lib "SSTVENG.DLL" (ByVal hSync As Long, ByVal hSpec As Long, ByVal hWater As Long, ByVal hLevel As Long)
Public Declare Sub mmsSetSpecRange Lib "SSTVENG.DLL" (ByVal base As Long, ByVal width As Long)
Public Declare Sub mmsSetSpecColor Lib "SSTVENG.DLL" (ByVal back As Long, ByVal sig As Long, ByVal persist As Long, ByVal marksync As Long, ByVal marksig As Long)
Public Declare Sub mmsSetWaterColor Lib "SSTVENG.DLL" (ByVal back As Long, ByVal sig As Long)
Can anyone give me some pointers to accessing these functions in VB.NET? I think I may need Marshalling or PINVOKE but know little about either. Some ideas for a starting point would be much appreciated.
Re: Using a third part DLL in VB.NET (examples in VB6)
Have you actually tried just carrying on in the same way? Unless you start getting unexpected errors I'd work on the policy that if it ain't broke don't fix it.
Re: Using a third part DLL in VB.NET (examples in VB6)
Quote:
Originally Posted by
dunfiddlin
Have you actually tried just carrying on in the same way? Unless you start getting unexpected errors I'd work on the policy that if it ain't broke don't fix it.
It didn't seem to work. A simple call to return the version umber of the DLL always returned 0. Should functions like that still work in VB.NET?
Re: Using a third part DLL in VB.NET (examples in VB6)
Is the Dll registered and on the Windows path (in system32 folder for example)?
Re: Using a third part DLL in VB.NET (examples in VB6)
Quote:
Originally Posted by
dunfiddlin
Is the Dll registered and on the Windows path (in system32 folder for example)?
No. The VB6 example doesn't do it that way.
Re: Using a third part DLL in VB.NET (examples in VB6)
A Long in VB6, is the now an Integer in .Net, that is a common one to change.
i.e:
Public Declare Function mmsGetVersion Lib "SSTVENG.DLL" () As Integer
Re: Using a third part DLL in VB.NET (examples in VB6)
Re: Using a third part DLL in VB.NET (examples in VB6)
These declarations are quite easy to convert.
Copy as is and change the following:-
- Longs to Integers
- Long pointers(hwnd) to IntPtr
Test it and if it works then I suggest following Technome's advice and use DLLImport instead. If it doesn;t work, then I can only guess P/Invoke isn;t passing the strings properly in which case I'll show you how.
Re: Using a third part DLL in VB.NET (examples in VB6)
Thanks guys (especially last three posts). I'll give it a go and report back.