Link to home
Start Free TrialLog in
Avatar of billy21
billy21

asked on

Invoking a dialup connection from code.

I am attempting to invoke a dial up connection from VB .NET.  I was hoping there would be an api call for this.  If there is I can't find it.  Can anybody point me in the right direction please?

Thanks,

Billy.
Avatar of hes
hes
Flag of United States of America image

Avatar of billy21
billy21

ASKER

Hes, that link was no good to me.  The app I downloaded from there appears to be for sending raw data down the com line.  There must be a higher level way of initiating a dialup connection than virtually writing my own modem drivers.
Avatar of billy21

ASKER

With my updated list of APIs I have come across this one:

    Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Integer, ByVal hwndParent As Integer) As Integer
    Const Internet_Autodial_Force_Online = 1
    Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2
    Const INTERNET_AUTODIAL_FAILIFSECURITYCHECK = 4
    Const INTERNET_AUTODIAL_FLAGS_MASK = (INTERNET_AUTODIAL_FORCE_ONLINE Or INTERNET_AUTODIAL_FORCE_UNATTENDED Or INTERNET_AUTODIAL_FAILIFSECURITYCHECK)


I have included most of the constants there but I am having trouble with hte hwndParent argument.  It expects a handle but I can't find any documentation relating to this handle.  Can anyone help with this?
Avatar of billy21

ASKER

I have tried calling it like this:

InternetAutodial(INTERNET_AUTODIAL_FLAGS_MASK, 0)

And Like this

InternetAutodial(Internet_Autodial_Force_Online, 0)

and a number of other combinations but the results in absolutely no response.  Not even an error message.
Avatar of billy21

ASKER

It appears that the handle in question is the form.  How do I express my form as a handle to parse as an argument of type integer?
Avatar of billy21

ASKER

In VB6 I can get the handle by looking up the hWnd property of the form object.  VB .NET doesn't seem to have this property.

I have found a property called handle: form1.ActiveForm.Handle

However, for some reason unknown to me 'ActiveForm' is set to nothing even though my form is loaded!
Avatar of billy21

ASKER

well I'm done with this question I solved the problem already.

I will award the points to somebody if they can point me to an API call that will tell me who the currently logged in user is in Windows XP home edition.
Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Avatar of billy21

ASKER

Can you tell me what I am doing wrong here?  I am trying to do this using VB .NET and to the best of my knowledge I can't use fixed length strings (ie. dim str as string * 20)

        Dim strBuffer As String
        Dim strlngth As Long

        strBuffer = "                    "
        strlngth = 20
        strlngth = 0
        MsgBox(GetUserName(strBuffer, strlngth))
        MsgBox(strBuffer)

The error I get is as follows:

An unhandled exception of type 'System.NullReferenceException' occurred in InternetConnect.exe

Additional information: Object reference not set to an instance of an object.


Thanks,

Billy
ASKER CERTIFIED SOLUTION
Avatar of twalgrave
twalgrave

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of billy21

ASKER

>In .Net, can't you simply use either:

I can't say for sure that you can't but I can say that if you can, you can't do it the same way that you do it in VB 6.

Thanks for the info it was very helpful.