Results 1 to 2 of 2

Thread: Help...Why the API dosen't work on vb.net?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    12

    Unhappy Help...Why the API dosen't work on vb.net?

    Hello,
    I 've faced with a problem when using APi in vb.net. The APi i used is working fine in vb6 but it seems not working in vb.net. Can anybody out there help me?

    **Problem:I want to check whether the MS Access driver is Exist in the pc or not... the API will return 0 (found) in vb6 but return numeric (not found) on vb.net.
    ** The driver is exist in this testing.

    May i know what's wrong with it?

    vb6

    Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByVal phkResult As Long) As Long

    Dim bRes As Boolean
    Dim lRes As Long
    Dim hKey As Long

    lRes = RegOpenKeyEx(&H80000002, _
    "SOFTWARE\ODBC\ODBCINST.INI\Microsoft Access Driver (*.mdb)", _
    0&, _
    &H1, _
    hKey)

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    that is because in VB6, data types where a$$ backwards and not standard with C data types. In VB .NET they are corrected. In the case of that API change all the Longs to Integer and it should work


    in comparison of data types

    VB6 VB .NET
    Integer - Short
    Long - Integer


    VB.NET has Long but it holds even higher values than VB6.

    You may want to search and read up more on using API in .NET also. This example is another reason why I keep telling people, you need to understand more about .NET, not just jump right in and start pasting your old VB6 code and expect it to work.


    Good Luck
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

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