Hello fellas,

I am making a project where modem's is the main concern..

but i really don't know where to start.

I have tried google how to make or detects a current modem that is existing. but i don't get what google is giving me. and most of them are vb6

anyone can point me

Basically, what i just need is.
How to Detect a modem..
i have tried detecting it. but it gives out the COM port only. but not the name

second, How to connect.

My purpose of this is to make a 1 Hit connect button, coz basically, we have a "USB 3G Modem USB Sticks" then everytime we want to connect we go to the panel of it.

What I want to make is like a simple

ComboBox which the modems will be Listed,
User will select the name of the modem that is Plugged in.

Then hit Connect. then it will automatically dialed the modem.

instead that would promt. it will automatically dial the number..
then it will just give out a notification icon or something status that is connected..

and also a button to just disconnect

pls help me.. Thanks
Hans Anderson.

Recommended Answers

All 7 Replies

  1. What OS and version are you using?
  2. What programming language do you want to use?
  3. How is the modem attached to the computer? Is it a serial modem, or USB?

Remember I will take your word this is a dial up modem and not some internet dongle.

The code would try opening com 0 to 255 and send out the old AT command and see if "OK" comes back. That's your basic scan and I should not have to code this for you.

But later in your post you have this USB 3G Modem and that's an entirely different kettle of fish. Those require setup and not scanning and dialing! If the setup is the same each time, most of the time you have a checkbox to "connect automatically."

On Cellular 3G connections, we don't dial.

Well because you not a modem manufacture, I think what will help you is to first detect USB/Ethernet cable insertion/removing. Every peripheral device connected to a computer usually first identifies it self into a computer and then offer/issue how it will be connected/contacted using(Port). So I think that might help as a start and my direct you to the right direction.

Once you have detected, you will have to check its description to see what it is: check this:

This is for detecting plugged and removed USB device with it drive letter:

 Public Enum WM_DEVICECHANGE_WPPARAMS As Integer
 DBT_CONFIGCHANGECANCELED = &H19
 DBT_CONFIGCHANGE = &H18
 DBT_CUSTOMEVENT = &H8006
 DBT_DEVICEARRIVAL = &H8000
 DBT_DEVICEQUERYREMOVE = &H8001
 DBT_DEVICEQUERYREMOVEFAILED = &H8002
 DBT_DEVICEREMOVECOMPLETE = &H8004
 DBT_DEVICEREMOVEPENDING = &H8003
 DBT_DEVICETYPESPECIFIC = &H8005
 DBT_DEVNODES_CHANGED = &H7
 DBT_QUERYCHANGECONFIG = &H17
 DBT_USERDEFINED = &HFFFF
 End Enum

 REM: Device info structure for table.

 Public Structure DEV_BROADCAST_HDR
 Public dbch_size As Int32
 Public dbch_devicetype As Int32
 Public dbch_reserved As Int32
 End Structure

 REM: Volume info Structure

 Private Structure DEV_BROADCAST_VOLUME
 Public dbcv_size As Int32
 Public dbcv_devicetype As Int32
 Public dbcv_reserved As Int32
 Public dbcv_uninmask As Int32
 Public dbcv_flags As Int16
 End Structure

 REM: Function to get drive letter

 Private Function GetDriveLetterFromMask(ByRef Unit As Int32) As Char
 For i As Integer = 0 to 25
 If Unit = (2 ^ i) Then
 Return Chr(Asc("A") + i)
 End If
 Next
 End Function

 REM: Implementation of WndProc() method

 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
 If QueryCancelAutoPlay = 0 Then
 QueryCancelAutoPlay = RegisterWindowsMessage("QueryCancelAutoPlay")
 End If
 If m.Msg = WM_DEVICECHANGE Then
 Select Case m.WParam
 Case WM_DEVICECHANGE_WPPARAMS.DBT_DEVICEARRIVAL
 REM: Device has been inserted/connected.

 Dim Volume As DEV_BROADCAST_VOLUME
 Volume = DirectCast(Marshal.PtrToStructure(m.LParam, GetType(DEV_BROADCAST_VOLUME)), DEV_BROADCAST_VOLUME)
 Dim DriveLetter As String = (GetDriveLetterFromMask(Volume.dbcv_unitmask) & ":\")
 Dim Counter As Integer
 For Counter = 0 To My.Computer.FileSystem.Drives.Counter -1
 If My.Computer.FileSystem.Drives(Counter).IsReady = True Then
 MsgBox("(" & DriverLetter & ")" & " " & My.Computer.FileSystem.Drives(Counter).VolumeLabel())
 detectorRemoval = +1
 End If
 Next
 REM: Now this is how you check.

 Case WM_DEVICECHANGE_WPPARAMS.DBT_DEVICEREMOVECOMPLETE
 detectorRemoval = -1
 MsgBox("USB has been removed")
 End Select
 End If
 MyBase.WndProc(m)
 End Sub

Basically you can also use this to also check the device connected type and based on it type you can do what ever you want.

Please , am using windows 8.1 pro (x64) , the language is VB.net and the connection is via USB

@Hans, time to get serious. No USB stick that provides the internet via cellular "dials." I had hoped for more detail from you but no go.

I wish I was there to see what you are trying to automate but I am not and here we are with a mess of a story. Take a moment to collect what you are working with (make/model) and then try again.

Just last month I had a friend with some USB stick that had to "connect" to the internet manually. For their stick it was some checkbox that needed to be checked and now it connects automatically. No code was required.

Senior , my project is to create a vb app which automatically detects any inserted modem , and to be able to connect it to the internet with a click of a button and also disconnect it with another.
So i was thinking about a simple form with a combo box to display the detected modems and to select the modem , a button to connect the selected modem to the internet and another to disconnect the modem from the internet .
Please , HELP ME OUT #rproffitt

@Hans. That's quite the ambitious project. What you'll learn along the way is that this might be possible for Dial Up Modems with a lot of caveats but for Cellular data modems, you would have to collect them all then create your detection system, driver fetch and install and then your settings system.

That's quite a lot of systems and code for each area.

Here's the lowdown. You won't be able to handle "any inserted modem" but only those that you coded for.

Frankly I don't see why anyone would do this given the costs and support issues it would incur. Figure a year for your first working app and many months of testing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.