Results 1 to 9 of 9

Thread: Using a third part DLL in VB.NET (examples in VB6)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    774

    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.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    774

    Re: Using a third part DLL in VB.NET (examples in VB6)

    Quote Originally Posted by dunfiddlin View Post
    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?

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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!

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    774

    Re: Using a third part DLL in VB.NET (examples in VB6)

    Quote Originally Posted by dunfiddlin View Post
    Is the Dll registered and on the Windows path (in system32 folder for example)?
    No. The VB6 example doesn't do it that way.

  6. #6
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    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

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Using a third part DLL in VB.NET (examples in VB6)

    Use DLLImport instead of Declare

    http://msdn.microsoft.com/en-us/library/w4byd5y4.aspx

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    774

    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
  •  



Click Here to Expand Forum to Full Width