?
Solved

Get the windows handle

Posted on 2004-10-19
6
Medium Priority
?
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 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