Initiate Dialup Connection

I need to automatically connect to the internet through the dialup networking app. It should dial the default account.

This needs to run on both NT and 95/98.

It looks like there are some procedures in C++, but I'm don't know how to interface that.
rngrovesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

st_steveCommented:
we can do that in VB as well...but I don't know how to dial the default...but I do know how to dial a connection...here's the code:

Public Sub DialNet(ByVal strConnectionName As String)
    'strConnectionName is case-sensitive! ("myconnection" <> "MyConnection")
    Dim res
    res = Shell("rundll32.exe rnaui.dll,RnaDial " _
    & strConnectionName, 1)
End Sub

nothing else to declare..when I know how to dial the default, I'll update the code again..
0
mcriderCommented:
Have you tried this:

     Shell "rundll rnaui.dll,RnaDial NAME", vbNormalFocus

where: NAME is the dial-up network name... For example, If my Dialup network name is: Erols Internet

Then I would do:

     Shell "rundll rnaui.dll,RnaDial Erols Internet", vbNormalFocus


You can find the default dialup name by going into the registry and getting the key:

HKEY_CURRENT_USER\RemoteAccess\InternetProfile

The following microsoft KB article shows you how to get information from the registry:

HOWTO: Use the Registry API to Save and Retrieve Setting
http://support.microsoft.com/support/kb/articles/q145/6/79.asp?LNG=ENG&SA=MSDN 
 


Cheers!
0
rngrovesAuthor Commented:
I've tried that...it says can't find rnaui.dll.

I'm thinking its a WinNT thing.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

st_steveCommented:
it's not winNT thing....it worked fine for my win 98 and win 95....let me think....
0
st_steveCommented:
can you dial the default connection manually? I mean can you go to "My Computer, dialup networking and see a connection profile....when you double-click on the profile, does it dial?? coz this profile also uses the dll that we (mcrider and me) are referencing....try tht first...if you can't connect, you might have to install dial up networking from Windows Components. (add/remove programs in control panel)
0
thangarajCommented:
How to handle Error during DialUp Connection ?
0
rngrovesAuthor Commented:
yeah, it has a default connection. And it actually dials automatically when I use a control like Inet Transfer Control, or when I enter a URL in my browser when I'm offline.

But after it connects, it never finds the URL it is looking for. I have to close the browser (or app), and open it up again.

So what I'm trying to do is dial first if there's no connection, then look for the URL.
0
thangarajCommented:
How to handle Error during DialUp Connection ?
0
thangarajCommented:
How to handle Error during DialUp Connection ?
0
st_steveCommented:
"thangaraj"..are you commenting on this question or are you trying to ask a question of your own?? seems like the second one.."How to handle Error during DialUp Connection ?"..seem a little unrelated to this question!
0
rngrovesAuthor Commented:
not really looking to handle errors. I'd rather just have the ability to call the dialup connector.
0
st_steveCommented:
"rngroves"...I'm kind of confused now...the problem seems like a browser problem...not dialup problem....if you can reinstall the browser, it might update the dll files that we're trying to reference...can you try reinstalling??
0
st_steveCommented:
if this doesn't work...let me think of another way to call the dialup dialog...
0
rngrovesAuthor Commented:
I've got IE 5 right now, is there any reason to downgrade?

And what if users don't have IE?
0
st_steveCommented:
I think it's not the IE5...but definitely a dll problem....can you find the dll manually? and see where it resides? it should be in %windir%\system directory so that all applications can access it...
0
rngrovesAuthor Commented:
rnaui.dll was not found anywhere on my hard drive.

I'm trying to tell you, NT is different than 95/98. NT uses something called Remote Access Services.
0
thangarajCommented:
Yes I got that How to Run Dialup Network ?.
1) How could i handle Error in case of any problem(No DialTone, Network Error etc) during dialing ?
2) How Can i check whether dialup was connected or not ?
0
rngrovesAuthor Commented:
thangarai - what do you think you're doing asking questions on my points?
0
st_steveCommented:
"thangaraj"..pls observe EE ethics...this is NOT your question! pls do not post any more of your questions here....if you want, clikc on "ask  a question now" on the top left hand of your page..

"rngroves"...you didn't mention that you were running WinNT..you just said it needs to run...maybe I didn't read your question properly...

I've written a module to check whether there's an internet connection (both LAN and DUN) present....using RAS...but I don't know how to dialup on WinNT...never much much experience programming for NT....if you want the module, I can give you...

0
rngrovesAuthor Commented:
yeah, sure...any code would be useful.

See this article from MS:
http://msdn.microsoft.com/workshop/networking/wininet/overview/establish.asp

These components look like what I need, but they're in C.
0
st_steveCommented:
ok...gimme your e address....coz the code is quite long....if I post it here...people might make noise...you know what I mean?? :)
0
cantrellCommented:
Here is how you get the "Default Dialup Connection"
-------------------------------------
Public Function Get_ISP_Name() As String

    Dim Hkey As Long
    Dim lpSubKey As String
    Dim phkResult As Long
    Dim lpValueName As String
    Dim lpReserved As Long
    Dim lpType As Long
    Dim lpData As String
    Dim lpcbData As Long
    Get_ISP_Name = ""

        lpSubKey = "RemoteAccess"
        ReturnCode = RegOpenKeyEx(HKEY_CURRENT_USER, lpSubKey, 0, KEY_ALL_ACCESS, phkResult)
       
            If ReturnCode = ERROR_SUCCESS Then
            Hkey = phkResult
            lpValueName = "Default"
            lpReserved = APINULL
            lpType = APINULL
            lpData = APINULL
            lpcbData = APINULL
            ReturnCode = RegQueryValueEx(Hkey, lpValueName, lpReserved, lpType, ByVal lpData, lpcbData)
            lpData = String$(lpcbData, 0)
            ReturnCode = RegQueryValueEx(Hkey, lpValueName, lpReserved, lpType, ByVal lpData, lpcbData)

            If ReturnCode = ERROR_SUCCESS Then Get_ISP_Name = Left$(lpData, lpcbData - 1)
           
            RegCloseKey (Hkey)
        End If

 '     End If
 
 
If Len(Get_ISP_Name) = 0 Then Get_ISP_Name = "NO DEFAULT ISP DETECTED!"

End Function
------------------------------
and here is how you auto connect to it...
-------------------------------
Shell "rundll32.exe rnaui.dll,RnaDial " & Get_ISP_Name, 1

-------------------------------
This works on Windows 95/98/NT and 2000.

I have been using this code for over a year now, and it works beautifully in all cases. Never had a problem.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rngrovesAuthor Commented:
st_steve: e-mail is r.groves@usa.net
0
rngrovesAuthor Commented:
cantrell: Using that shell routine hasn't previously worked for me, since "rnaui.dll" does not exist anywhere on my hard drive.

Anyway, I tried your code but you didn't include the sub for "RegOpenKeyEx"
0
cantrellCommented:
It's "Rnaui.dll", although it looks like rnaui.dll when they convert my fonts in lower case.

here is the regopenkeyex decleration...
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal Hkey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
0
rngrovesAuthor Commented:
I get this error from the RegOpenKey declaration when I try to run the prog:
"Constants, fixed-length strings, arrays, user-defined types and Declare statements not allowed as public members of object modules"

I tried putting it in a separate module (main.bas) but then the form could find it.
0
rngrovesAuthor Commented:
Oh wait, putting it in main.bas worked, but now there's another undefined proc:
RegQueryValueEx
0
cantrellCommented:
Here, this should cover it all. it's my own personal 'registry32.bas' file I include in every project if I do any registry things. This is a big one, but it will cover everything...

Just make this it's own .bas module

Option Explicit

'Registry Functions.
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegCreateKeyEx Lib "advapi32" Alias "RegCreateKeyExA" (ByVal Hkey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As typSECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal Hkey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal ReturnedRegValue As String, ByVal cbData As Long) As Long
Declare Function RegConnectRegistry Lib "advapi32.dll" Alias "RegConnectRegistryA" (ByVal lpMachineName As String, ByVal Hkey As Long, phkResult As Long) As Long
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal Hkey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal ReturnedRegValue As String, ByVal cbData As Long) As Long
Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long
Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal ReturnedRegValue As String, lpcbData As Long) As Long
Declare Function RegDeleteKey& Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String)
Declare Function RegDeleteValue& Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal Hkey As Long, ByVal lpSubKey As String)
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal Hkey As Long, ByVal dwIndex As Long, ByVal lpname As String, cbName As Long) As Long
Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal Hkey As Long, ByVal dwIndex As Long, ByVal lpname As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long
Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal Hkey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
'Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long

'Drive information.
Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long



'For form position
Public Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Const HWND_TOPMOST = -1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_SHOWWINDOW& = &H40
Public Const HWND_BOTTOM& = 1

 
'Security Mask constants
Public Const READ_CONTROL = &H20000
Public Const SYNCHRONIZE = &H100000
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const STANDARD_RIGHTS_READ = READ_CONTROL
Public Const STANDARD_RIGHTS_WRITE = READ_CONTROL
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const KEY_CREATE_LINK = &H20
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Public Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE))
Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))

'Predefined Registry Keys used in hKey Argument
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANCE_DATA = &H80000004

' Return codes from Registration functions.
Public Const ERROR_SUCCESS = 0&
Public Const ERROR_BADDB = 1009&
Public Const ERROR_BADKEY = 1010&
Public Const ERROR_CANTOPEN = 1011&
Public Const ERROR_CANTREAD = 1012&
Public Const ERROR_CANTWRITE = 1013&
Public Const ERROR_OUTOFMEMORY = 14&
Public Const ERROR_INVALID_PARAMETER = 87&
Public Const ERROR_ACCESS_DENIED = 5&

'Data type Public Constants
Public Const REG_NONE = 0
Public Const REG_SZ = 1
Public Const REG_EXPAND_SZ = 2
Public Const REG_BINARY = 3
Public Const REG_DWORD = 4
Public Const REG_DWORD_LITTLE_ENDIAN = 4
Public Const REG_DWORD_BIG_ENDIAN = 5
Public Const REG_LINK = 6
Public Const REG_MULTI_SZ = 7
Public Const REG_RESOURCE_LIST = 8
Public Const REG_FULL_RESOURCE_DESCRIPTOR = 9
Public Const REG_RESOURCE_REQUIREMENTS_LIST = 10

'for regenumvalue's modified key time.
Public Type FILETIME
   dwLowDateTime As Long
   dwHighDateTime As Long
End Type

'Options
Public Const REG_OPTION_NON_VOLATILE = 0&
Public Const REG_OPTION_VOLATILE = &H1

Type typSECURITY_ATTRIBUTES
  nLength As Long
  lpSecurityDescriptor As Variant
  bInheritHandle As Long
End Type

Public Sub UpdateRegistry2(Hkey As Long, KeyToChange As String, NewValue As String, NameValue As String)

      Dim keyhandle As Long          'To hold the KeyHandle number returned by opening the Registry key.
      Dim dataSize As Long           'Size of the Data (string) we are changing (including the terminating /0).
      Dim ReturnCode As Long         'Holds the return code of the process (i.e. if there was an error).
      Dim ReturnedRegValue As String

        'Open the Registry Key.
     ReturnCode = RegOpenKeyEx(Hkey, KeyToChange, 0, KEY_ALL_ACCESS, keyhandle)
          'If we can't open the key then it's not there so we need to create it.
          If ReturnCode <> 0 Then ReturnCode = RegCreateKey(Hkey, KeyToChange, keyhandle)
      If ReturnCode <> 0 Then MsgBox "Error Updating Registry", vbCritical, "UpdateRegistry2 Module": Exit Sub
     
        'Change the Registry Key.
      ReturnCode = RegSetValueEx(keyhandle, NameValue, 0, REG_SZ, NewValue, Len(KeyToChange) + 1)
          'Check for error
        If ReturnCode <> 0 Then MsgBox "Error Updating Registry", vbCritical, "UpdateRegistry2 Module": Exit Sub

        'Close the Registry Key.
     ReturnCode = RegCloseKey(keyhandle)
End Sub

Public Sub gAPIDisplayError(Code&, Optional keyhandle As Long, Optional keyname As String)

                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''                                                                                 '''
        ''' The subroutine gAPIDisplayError processes Code&. Code& is returned by a         '''
        '''     function calling one of the Win32 API Registry functions, and describes     '''
        '''     the end result of the function call. The value returned by Win32 API        '''
        '''     Registry functions are constants defined in Registry32.declarations. If the '''
        '''     function call was executed sucessfully, it will return ERROR_SUCCESS, which '''
        '''     requires no follow up action. If the function call was executed             '''
        '''     unsuccessfully, it will return one of the below values. The only follow up  '''
        '''     action performed by this subroutine is to issue an error message to the     '''
        '''     screen, halting execution until the OK button is pressed.                   '''
        '''                                                                                 '''
        ''' The passed parameters are:                                                      '''
        '''     Code& - returned by a function calling one of the Win32 API Registry        '''
        '''         functions, describing the end result of the function call.              '''
        '''                                                                                 '''
        ''' The function performs the following tasks in corresponding order:               '''
        '''     1) Perform a Select routine on Code&, and issue the respective error        '''
        '''         message to the screen.                                                  '''
        '''                                                                                 '''
        ''' Since this module uses the Win32 API, it is only functional on Win95 and WinNT  '''
        '''     systems.                                                                    '''
        '''                                                                                 '''
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '' Perform a Select routine on Code&, and issue the respective error message ''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        Select Case Code&
            Case ERROR_SUCCESS
                'Don't return an error message
         Case ERROR_BADDB
              MsgBox "Corrupt Registry Database!", vbCritical, "Registry Error!"
         Case ERROR_BADKEY
              MsgBox "Key name is bad! - " & keyname, vbCritical, "Registry Error!"
         Case ERROR_CANTOPEN
             MsgBox "Cannot Open Key! - " & keyname, vbCritical, "Registry Error!"
         Case ERROR_CANTREAD
              MsgBox "Cannot Read Key! - " & keyname, vbCritical, "Registry Error!"
         Case ERROR_CANTWRITE
             MsgBox "Cannot Write to Registry!" + Chr$(13) + "If you are running Windows NT YOU MUST BE LOGGED IN AS ADMINISTRATOR", vbCritical, "Registry Error!"
         Case ERROR_ACCESS_DENIED
             MsgBox "Access to Registry Denied!" + Chr$(13) + "If you are running Windows NT YOU MUST BE LOGGED IN AS ADMINISTRATOR", vbCritical, "Registry Error!"
         Case ERROR_OUTOFMEMORY
             MsgBox "Out of memory", vbCritical, "Registry Error!"
         Case ERROR_INVALID_PARAMETER
             MsgBox "Invalid Parameter", vbCritical, "Registry Error!"
         Case Else
             MsgBox "Undefined key error code: " + keyname, vbCritical, "Registry Error!"
             MsgBox "Attempting registry error recovery", vbOKOnly, "Registry Recovery"
         End Select



End Sub


Public Function RegistryOpenKey(hWndAlreadyOpenedKey&, OpenThisKey$) As Long

                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''                                                                                 '''
        ''' The function RegistryOpenKey opens the key OpenThisKey$ under the already       '''
        '''     opened registry key hWndAlreadyOpenedKey&, returning the handle to the new  '''
        '''     key.                                                                        '''
        ''' Note that after a key is finished being used, it should be closed with          '''
        '''     Registry32.RegistryCloseKey.                                                '''
        '''                                                                                 '''
        ''' The passed parameters are:                                                      '''
        '''     hWndAlreadyOpenedKey& - the handle to the already opened key (see the       '''
        '''         function Registry32.RegistryOpenKey). Note that the keys                '''
        '''         Handle, it's subkey HKEY_CLASSES_ROOT, Handle, it's     '''
        '''         subkey HKEY_CURRENT_USER, and the rarely used HKEY_PERFORMANCE_DATA     '''
        '''         are handles that are constants, and thus are already opened. They don't '''
        '''         need to be closed.                                                      '''
        '''     OpenThisKey$ - the name of the key to be opened. It must be under an        '''
        '''         already opened key.                                                     '''
        '''                                                                                 '''
        ''' The function declaration for RegOpenKeyEx was taken from the (Jan96) MSDN       '''
        '''     and from WIN32API.TXT. It is declared in Registry32.declarations.           '''
        ''' The parameters used with RegOpenKeyEx are defined in the (Jan96) MSDN in        '''
        '''     \Product Documentation\SDKs\Win32 SDK\Win32 Programmer's Reference\         '''
        '''     \Reference\Functions\ReadEventLog to RemoveMenu\RegOpenKeyEx.               '''
        '''     hWndAlreadyOpenedKey& - the handle to the already opened key (see the       '''
        '''         function Registry32.RegistryOpenKey). Note that the keys                '''
        '''         Handle, it's subkey HKEY_CLASSES_ROOT, Handle, it's     '''
        '''         subkey HKEY_CURRENT_USER, and the rarely used HKEY_PERFORMANCE_DATA     '''
        '''         are handles that are constants, and thus are already opened. They don't '''
        '''         need to be closed.                                                      '''
        '''     OpenThisKey$ - the name of the key to be opened. It must be under an        '''
        '''         already opened key.                                                     '''
        '''     0& - Reserved by the API, not used.                                         '''
        '''     KEY_ALL_ACCESS - the security access desired for the key. Here it is        '''
        '''         assumed the created key will have all access permissions.               '''
        '''     hWndOpenedKey& - placeholder for RegOpenKeyEx to enter the handle to the    '''
        '''         opened key.                                                             '''
        '''     lReturn - a constant returned describing the success/failure of the         '''
        '''         function. The constants are defined in the declarations section, and    '''
        '''         processed by Registry32.gAPIDisplayError.                               '''
        '''                                                                                 '''
        ''' The function performs the following tasks in corresponding order:               '''
        '''     1) Open the key OpenThisKey$ under the key hWndAlreadyOpenedKey&.           '''
        '''     2) Process lReturn. For details, see the documentation for                  '''
        '''         Registry32.gAPIDisplayError.                                            '''
        '''     3) Return the handle to the newly opended key to the calling procedure.     '''
        '''                                                                                 '''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


      Dim hWndOpenedKey&                   'the handle of the key opened by RegOpenKeyEx
      Dim lReturn As Long                  'the error value returned by the registry function



                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '' Open the key OpenThisKey$ under the key hWndAlreadyOpenedKey& ''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      lReturn = RegOpenKeyEx(hWndAlreadyOpenedKey&, OpenThisKey$, 0&, KEY_ALL_ACCESS, hWndOpenedKey&)


                                        '''''''''''''''''''''
        '' Process lReturn ''
                                        '''''''''''''''''''''
      Call modRegistry32.gAPIDisplayError(lReturn)


                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '' Return the handle to the newly opended key to the calling procedure ''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      RegistryOpenKey = hWndOpenedKey&


End Function

Public Function RegistryQueryValue(RegistryKey&, ValueName$, ValueDataType&, Optional keyname As String) As String
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''                                                                                 '''
        ''' The function RegistryQueryValue queries the value from an already opened        '''
        '''     registry key, returning it as a string, given the below parameters.         '''
        ''' The passed parameters are:                                                      '''
        '''     RegistryKey& - the handle to the already opened key (see the                '''
        '''         Registry32.RegistryOpenKey or Registry32.RegistryCreateKey functions).  '''
        '''     ValueName$ - the name of the value to be queried. If an empty string is     '''
        '''         passed to it, it will grab the "default" value.                         '''
        '''     ValueDataType& - the type of value to grab. See the constants in the        '''
        '''         Registry32.declarations section for acceptable values to pass.          '''
        '''                                                                                 '''
        ''' The function declaration for RegQueryValueEx was taken from the (Jan96) MSDN    '''
        '''     and from WIN32API.TXT. It is declared in the declarations section.          '''
        ''' The parameters used with RegQueeryValueEx are defined in the (Jan96) MSDN in    '''
        '''     \Product Documentation\SDKs\Win32 SDK\Win32 Programmer's Reference\         '''
        '''     \Reference\Functions\ReadEventLog to RemoveMenu\RegQueeryValueEx.           '''
        '''     RegistryKey& - the handle to the already opened key (see the                '''
        '''         Registry32.RegistryOpenKey or Registry32.RegistryCreateKey functions).  '''
        '''     ValueName$ - the name of the value to be queried. If an empty string is     '''
        '''         passed to it, it will grab the "default" value. The pointer to the      '''
        '''         string is passed (VB ByVal for strings).                                '''
        '''     0& - Reserved by the API, not used.                                         '''
        '''     ValueDataType& - the type of value to grab. See the constants in the        '''
        '''         Registry32.declarations section for acceptable values to pass.  The     '''
        '''         pointer to the buffer is passed (VB ByRef).                             '''
        '''     ReturnedRegValue - the pointer to the buffer that holds the queried data.             '''
        '''     lpcbData - the pointer to the size of the buffer pointed to by ReturnedRegValue       '''
        '''     lReturn - a constant returned describing the success/failure of the         '''
        '''         function. The constants are defined in the declarations section, and    '''
        '''         processed by Registry32.gAPIDisplayError.                               '''
        '''                                                                                 '''
        ''' The function has a Select statement according to the type of data held in the   '''
        '''     Registry key's value:                                                       '''
        '''     REG_SZ and REG_EXPAND_SZ uses the left$ VB function to remove the NULL      '''
        '''         character at the end the string.                                        '''
        '''     REG_MULTI_SZ returns the first string, fills in the variant variable-size   '''
        '''         array if passed. Note that the passed array will have all previous      '''
        '''         values lost.                                                            '''
        '''     REG_BINARY requires the translation of the unreadable binary data into      '''
        '''         readable hex format. The translation is performed by                    '''
        '''         Registry32.BinaryInStringToHexInString. Note that VB can't directly     '''
        '''         handle binary data.                                                     '''
        '''                                                                                 '''
        ''' The function performs the following tasks in corresponding order:               '''
        '''     1) Identify the data type of the value being queried. The acceptable        '''
        '''         options are REG_SZ and REG_EXPAND_SZ (NULL terminated string), and      '''
        '''         REG_BINARY (binary data without a termination character).               '''
        '''     2) Dimension the size of the data buffer. This includes having it take up   '''
        '''         the desired memory space by filling it with space characters, and       '''
        '''         declaring the size of the buffer (lpcbData). Note that passing a VB     '''
        '''         string By Val (see the function declaration for RegQueryValueEx in      '''
        '''         Registry32.declarations) passes the pointer to the string, not the      '''
        '''         actual string itself.                                                   '''
        '''     3) Query the data from the Registry value.                                  '''
        '''     4) Process lReturn. For details, see the documentation for                  '''
        '''         Registry32.gAPIDisplayError.                                            '''
        '''     5) Return the queried value as a string to the calling procedure.           '''
        '''                                                                                 '''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


      Dim ReturnedRegValue As String       'the pointer to the buffer that holds the queried data
      Dim lpcbData As Long                 'the pointer to the size of the buffer pointed to by ReturnedRegValue
      Dim lReturn As Long                  'the error value returned by the registry function


                                        '''''''''''''''''''''''''''''''''''''''''''
        '' Dimension the size of the data buffer ''
                                        '''''''''''''''''''''''''''''''''''''''''''
              lpcbData = 255
              ReturnedRegValue = Space$(lpcbData)
       
                                        ''''''''''''''''''''''''''''''''''''''''''''
        '' Query the data from the Registry value ''
                                        ''''''''''''''''''''''''''''''''''''''''''''
              lReturn = RegQueryValueExString(RegistryKey&, ValueName$, 0&, ValueDataType&, ReturnedRegValue, lpcbData)
       
                                        '''''''''''''''''''''
        '' Process lReturn ''
                                        '''''''''''''''''''''
              Call modRegistry32.gAPIDisplayError(lReturn, RegistryKey, keyname)
       
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '' Return the queried value as a string to the calling procedure ''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
               RegistryQueryValue = Left$(ReturnedRegValue, lpcbData)
 
End Function

Public Sub RegistryCloseKey(CloseThisKey&)
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''                                                                                 '''
        ''' The subroutine RegistryCloseKey closes the key CloseThisKey&. "Closing" the     '''
        '''     key "gives" the key back to the NT OS, releasing it's resources (handle).   '''
        '''     After a key is closed, it is no longer usable by the program (unless        '''
        '''     reopened). After a Registry key is opened (see                              '''
        '''     Registry32.RegistryCreateKey and Registry32.RegistryOpenKey) it should be   '''
        '''     closed shortly after it is done being used.                                 '''
        '''                                                                                 '''
        ''' The passed parameters are:                                                      '''
        '''     CloseThisKey& - the handle to the key to be closed. Presumably, it is a     '''
        '''         key that has been opened/created but hasn't been closed yet. (see the   '''
        '''         functions Registry32.RegistryOpenKey, Registry32.RegistryCreateKey, and '''
        '''         Registry32.RegistryWriteValue).                                         '''
        '''                                                                                 '''
        ''' The function declaration for RegCloseKey was taken from the (Jan96) MSDN        '''
        '''     and from WIN32API.TXT. It is declared in Registry32.declarations.           '''
        ''' The parameters used with RegCloseKey are defined in the (Jan96) MSDN in         '''
        '''     \Product Documentation\SDKs\Win32 SDK\Win32 Programmer's Reference\         '''
        '''     \Reference\Functions\ReadEventLog to RemoveMenu\RegCloseKey.                '''
        '''     CloseThisKey& - the handle to the key to be closed. Presumably, it is a     '''
        '''         key that has been opened/created but hasn't been closed yet. (see the   '''
        '''         functions Registry32.RegistryOpenKey, Registry32.RegistryCreateKey, and '''
        '''         Registry32.RegistryWriteValue).                                         '''
        '''     lReturn - a constant returned describing the success/failure of the         '''
        '''         function. The constants are defined in Registry32.declarations and      '''
        '''         processed by Registry32.gAPIDisplayError.                               '''
        '''                                                                                 '''
        ''' The function performs the following tasks in corresponding order:               '''
        '''     1) Close the key CloseThisKey&, and assign the result to lReturn.           '''
        '''     2) Process lReturn. For details, see the documentation for                  '''
        '''         Registry32.gAPIDisplayError.                                            '''
        '''                                                                                 '''
        ''' Since this module uses the Win32 API, it is only functional on Win95 and WinNT  '''
        '''     systems.                                                                    '''
        '''                                                                                 '''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


      Dim lReturn As Long                  'the error value returned by the registry function


                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '' Close the key CloseThisKey&, and assign the result to lReturn ''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      lReturn = RegCloseKey(CloseThisKey&)


                                        '''''''''''''''''''''
        '' Process lReturn ''
                                        '''''''''''''''''''''
      Call modRegistry32.gAPIDisplayError(lReturn)

End Sub

Public Function RegistryCreateKey(hWndAlreadyOpenedKey&, CreateThisKey$) As Long
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''                                                                                 '''
        ''' The function RegistryCreateKey creates the key CreateThisKey$ under the         '''
        '''     already opened registry key hWndAlreadyOpenedKey&, returning the handle to  '''
        '''     the new key. If the key already exists, it merely opens the key, returning  '''
        '''     it's handle.                                                                '''
        ''' Note that after a key is finished being used, it should be closed with          '''
        '''     Registry32.RegistryCloseKey.                                                '''
        '''                                                                                 '''
        ''' The passed parameters are:                                                      '''
        '''     hWndAlreadyOpenedKey& - the handle to the already opened key (see the       '''
        '''         function Registry32.RegistryOpenKey). Note that the keys                '''
        '''         Handle, it's subkey HKEY_CLASSES_ROOT, Handle, it's     '''
        '''         subkey HKEY_CURRENT_USER, and the rarely used HKEY_PERFORMANCE_DATA     '''
        '''         are handles that are constants, and thus are already opened. They don't '''
        '''         need to be closed.                                                      '''
        '''     CreateThisKey$ - the name of the key to be created. If the key already      '''
        '''         exists, it merely opens it. Registry32.RegistryCreateKey returns the    '''
        '''         handle to this key.                                                     '''
        '''                                                                                 '''
        ''' The function declaration for RegCreateKeyEx was taken from the (Jan96) MSDN     '''
        '''     and from WIN32API.TXT. It is declared in Registry32.declarations.           '''
        ''' The parameters used with RegCreateKeyEx are defined in the (Jan96) MSDN in      '''
        '''     \Product Documentation\SDKs\Win32 SDK\Win32 Programmer's Reference\         '''
        '''     \Reference\Functions\ReadEventLog to RemoveMenu\RegCreateKeyEx.             '''
        '''     hWndAlreadyOpenedKey& - the handle to the already opened key (see the       '''
        '''         notes above).                                                           '''
        '''     CreateThisKey$ - the name of the key to be created. If the key already      '''
        '''         exists, it merely opens it. Registry32.RegistryCreateKey returns the    '''
        '''         handle to this key.                                                     '''
        '''     0& - Reserved by the API, not used.                                         '''
        '''     "" - Not currently being used. A string that specifies the class (object    '''
        '''         type) of the key being created.                                         '''
        '''     REG_OPTION_NON_VOLATILE - special options for the key being created. The    '''
        '''         option is here assumed to make the key "permanaent" as opposed to       '''
        '''         temporarily existing in memory until bootup (REG_OPTION_VOLATILE).      '''
        '''         Registry32.declarations section for acceptable values to pass.  The     '''
        '''         pointer to the buffer is passed (VB ByRef).                             '''
        '''     KEY_ALL_ACCESS - the security access desired for the key. Here it is        '''
        '''         assumed the created key will have all access permissions.               '''
        '''     lpSecurityAttributes - pointer to a security structure that defines the     '''
        '''         security for the key. Here the system defaults are assumed by leaving   '''
        '''         value at NULL.                                                          '''
        '''     hWndCreatedKey& - placeholder for RegCreateKeyEx to enter the handle to the '''
        '''         key created or opened.                                                  '''
        '''     lpdwDisposition - Memory space for RegCreateKeyEx to dump unwanted status   '''
        '''         information of the key before it was created/opened.                    '''
        '''     lReturn - a constant returned describing the success/failure of the         '''
        '''         function. The constants are defined in the declarations section, and    '''
        '''         processed by Registry32.gAPIDisplayError.                               '''
        '''                                                                                 '''
        ''' The function performs the following tasks in corresponding order:               '''
        '''     1) Create the key CreateThisKey$ under the key hWndAlreadyOpenedKey&.       '''
        '''     2) Process lReturn. For details, see the documentation for                  '''
        '''         Registry32.gAPIDisplayError.                                            '''
        '''     3) Return the handle to the newly created/opended key to the calling        '''
        '''         procedure.                                                              '''
        '''                                                                                 '''
        ''' Since this module uses the Win32 API, it is only functional on Win95 and WinNT  '''
        '''     systems.                                                                    '''
        '''                                                                                 '''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


      Dim hWndCreatedKey&                                 'The handle to the key created/opened by RegCreateKeyEx
      Dim lpdwDisposition As Long                         'Memory space for RegCreateKeyEx to dump unwanted status information of the key before it was created/opened
      Dim lpSecurityAttributes As typSECURITY_ATTRIBUTES     'left$ at NULL to accept the default security attributes
      Dim lReturn As Long                                  'the error value returned by the registry function


                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '' Create the key CreateThisKey$ under the key hWndAlreadyOpenedKey& ''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      lReturn = RegCreateKeyEx(hWndAlreadyOpenedKey&, CreateThisKey$, 0&, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, lpSecurityAttributes, hWndCreatedKey&, lpdwDisposition)


                                        '''''''''''''''''''''
        '' Process lReturn ''
                                        '''''''''''''''''''''
      Call modRegistry32.gAPIDisplayError(lReturn)


                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '' Return the handle to the newly created/opended key to the calling procedure ''
                                        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      RegistryCreateKey = hWndCreatedKey&

End Function
0
rngrovesAuthor Commented:
Well, thanks for all your effort. But as before, I'm still getting an error associated with Rnaui.dll.

This is the shell statement I have:
Shell "rundll32.exe rnaui.dll,RnaDial " & Get_ISP_Name, 1

Error:
Error loading rnaui.dll

The specified module could not be found.
0
cantrellCommented:
This is a file that is installed by default with every windows system. I don't know why you don't have it.
However, I put it on the net for you to download. You can get it at: http://www.trusted.net/~cantrell/RNAUI.DLL
0
st_steveCommented:
do you still need my code, rngroves?
0
rgrovesCommented:
st_steve: I think cantrell's code will do the job, but I can't try it out till tonight. Go ahead and email the code if you don't mind.

Thanks.
0
rgrovesCommented:
Cantrell: I tried looking for it on my work computer, which is also NT, and it is not there.
0
cantrellCommented:
Then you can download it from the site I listed above....
0
rngrovesAuthor Commented:
My point being, it doesn't seem to be a "default install". Am I to include it when I package my application for deployment?
0
rngrovesAuthor Commented:
I have performed searches on 2 NT4 machines, 2 Win95 machines, and 1 Win2000 machine..

Rnaui.dll was only found on one of the Win95 machines.
0
cantrellCommented:
I just checked my Windows NT 4.0 machine and it was found in the 'C:\WinNT\System32' directory.

I also checked the code on this same machine and it works.

I don't see how it would hurt though, to include this in your setup program, since it is such a small file.
0
st_steveCommented:
I'll wait until you need the code..I don't want to flood your mailbox....and I'm sure "cantrell"'s code will work...
0
rngrovesAuthor Commented:
Cantrell: Still not working. The rnaui.dll is in my system directory but the command won't execute. I get the error:

"The specified procedure could not be found."

I think its looking for "RnaDial" in the line..
Shell "rundll32.exe rnaui.dll,RnaDial " & Get_ISP_Name, 1
0
cantrellCommented:
do you have service pack 5 on that nt machine?
0
rngrovesAuthor Commented:
yes, i have sp5.
0
rngrovesAuthor Commented:
Well, never got it working, but you deserve the points.

Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.