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.
Thanks,
Billy.
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.
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_On line = 1
Const INTERNET_AUTODIAL_FORCE_UN ATTENDED = 2
Const INTERNET_AUTODIAL_FAILIFSE CURITYCHEC K = 4
Const INTERNET_AUTODIAL_FLAGS_MA SK = (INTERNET_AUTODIAL_FORCE_O NLINE Or INTERNET_AUTODIAL_FORCE_UN ATTENDED Or INTERNET_AUTODIAL_FAILIFSE CURITYCHEC K)
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?
Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Integer, ByVal hwndParent As Integer) As Integer
Const Internet_Autodial_Force_On
Const INTERNET_AUTODIAL_FORCE_UN
Const INTERNET_AUTODIAL_FAILIFSE
Const INTERNET_AUTODIAL_FLAGS_MA
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?
ASKER
I have tried calling it like this:
InternetAutodial(INTERNET_ AUTODIAL_F LAGS_MASK, 0)
And Like this
InternetAutodial(Internet_ Autodial_F orce_Onlin e, 0)
and a number of other combinations but the results in absolutely no response. Not even an error message.
InternetAutodial(INTERNET_
And Like this
InternetAutodial(Internet_
and a number of other combinations but the results in absolutely no response. Not even an error message.
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?
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!
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!
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.
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
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(strBuff er, strlngth))
MsgBox(strBuffer)
The error I get is as follows:
An unhandled exception of type 'System.NullReferenceExcep tion' occurred in InternetConnect.exe
Additional information: Object reference not set to an instance of an object.
Thanks,
Billy
Dim strBuffer As String
Dim strlngth As Long
strBuffer = " "
strlngth = 20
strlngth = 0
MsgBox(GetUserName(strBuff
MsgBox(strBuffer)
The error I get is as follows:
An unhandled exception of type 'System.NullReferenceExcep
Additional information: Object reference not set to an instance of an object.
Thanks,
Billy
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
http://www.freevbcode.com/ShowCode.Asp?ID=4666