|
-
Oct 15th, 2012, 04:34 PM
#1
Thread Starter
Fanatic Member
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.
-
Oct 15th, 2012, 04:49 PM
#2
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.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Oct 15th, 2012, 05:22 PM
#3
Thread Starter
Fanatic Member
Re: Using a third part DLL in VB.NET (examples in VB6)
 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?
-
Oct 15th, 2012, 05:32 PM
#4
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)?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Oct 16th, 2012, 02:00 AM
#5
Thread Starter
Fanatic Member
Re: Using a third part DLL in VB.NET (examples in VB6)
 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.
-
Oct 16th, 2012, 10:34 AM
#6
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
-
Oct 16th, 2012, 10:39 AM
#7
Re: Using a third part DLL in VB.NET (examples in VB6)
-
Oct 16th, 2012, 10:57 AM
#8
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.
-
Oct 16th, 2012, 01:18 PM
#9
Thread Starter
Fanatic Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|