Solved

Get the windows handle

Posted on 2004-10-19
6
279 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now