Solved

Get the windows handle

Posted on 2004-10-19
6
297 Views
Last Modified: 2008-02-20
Hello,

I'm trying to establish an internet connection using the InternetAutodial function.  The second parameter you need to pass is the windows handle (I'm using it on a PDA, so .NET COMPACT FRAMEWORK is used).

How can I get the windows handle in vb.net ?

This is the code I use now :

Private Const INTERNET_AUTODIAL_FORCE_ONLINE = 1
Private Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2

InternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED, 0&)

This returns this error : NotSupportedException
0
Comment
Question by:ACAE
  • 4
  • 2
6 Comments
 
LVL 3

Expert Comment

by:jazduck
ID: 12345407
Dim objProcess As New Process()
        Dim objProcesses() As Process '
        objProcesses = Process.GetProcesses()

iWnd = objProcess.MainWindowHandle.ToInt32()

Along those lines, sorry I cant currently test anything, laptop's decided it doesnt like me (again).

Regards
Jaz
0
 

Author Comment

by:ACAE
ID: 12345447
I have 2 problems :
- Process type doesn't seem to be supported by the .net compact framework
- If I try this on a normal windows application, I get an error : 'No process is associated with this object'

Any ideas ?
0
 
LVL 3

Expert Comment

by:jazduck
ID: 12353935
Ill have another look at it today, I pulled this out of some code i use to setfocus back to my application using its hwnd, ill just have to see what bits I missed. But first im going to have to install vs.net again, thats a nice hour wait to think about it :)
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 3

Expert Comment

by:jazduck
ID: 12354358

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        GetHandle(Me.Name) 'Call using WindowTitle as parameter
    End Sub

    Sub GetHandle(ByVal strWindowTitle As String)
        Dim hWnd As Long
        Dim objProcess As New Process()
        Dim objProcesses() As Process

        objProcesses = Process.GetProcesses()

        For Each objProcess In objProcesses
            If UCase(objProcess.MainWindowTitle) = UCase(strWindowTitle) Then
                hWnd = objProcess.MainWindowHandle.ToInt32()
                Exit For
            End If
        Next
        MsgBox(hWnd)
    End Sub

That does the trick
Regards
Jaz
0
 
LVL 3

Accepted Solution

by:
jazduck earned 125 total points
ID: 12354488
If it doesnt work with the compact framework, Im not too sure how else to approach this.

Hopefully it will :)

Jaz
0
 

Author Comment

by:ACAE
ID: 12355600
The problem is that with the compact framework the type 'processed' is not supported.  Anyhow, we bought a dll from another company (intelliprog) whch does the job.  Thanx for your help
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question