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
Solved

Get the windows handle

Posted on 2004-10-19
6
304 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Advice in Xamarin 21 96
Import Data from Multiple Text Files in Excel 12 58
VB.Net WebRequest Code from JSON curl 7 49
vb.net and creating a class 5 20
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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 …

808 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