?
Solved

vncviewer.exe in vb app

Posted on 2004-08-31
9
Medium Priority
?
698 Views
Last Modified: 2008-02-01
Hi I have vnc running in all computers in my network. I have a managing application that I created and I just want to know if it's possible to implement vnviewer to it. I just want a simple example of how can I call on the viewer with a specific computer name and password. If possible also to be able change some of the settings like full screen. Please tell me this is possible.
0
Comment
Question by:DARKSAGES
[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
  • 6
  • 3
9 Comments
 
LVL 7

Expert Comment

by:jacobhoover
ID: 11945895
There are some command line switches to the viewer but you can also save the connection information as a .vnc file.  If you looked at the format of the .vnc file it would be possible to dynamically create the file and then just shell to vnc passing it the path to the .vnc file.
0
 
LVL 7

Expert Comment

by:jacobhoover
ID: 11947124
Other options include:
/8bit
/shared
/noshared
/swapmouse
/belldeiconify
/listen
/fullscreen
/viewonly
/emulate3
/scale a/b
/config configfile  <-- This was the one I was talking about
/encoding encname
/compresslevel n
/quality n
/nocursorshape
/noremotecursor
 server[:display]
0
 
LVL 7

Expert Comment

by:jacobhoover
ID: 11947287
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long


Private Const SYNCHRONIZE = &H100000
Private Const INFINITE = &HFFFF      '  Infinite timeout

Const PathToVNCViewer = "C:\<<Path Too>>\tightvnc-1.2.2_x86_viewer\vncviewer.exe"
Public Sub Connect(szMachine As String)
  Call ShellAndWait(PathToVNCViewer & " /8bit /shared /viewonly " & szMachine, vbNormalFocus)
End Sub

' Start the indicated program and wait for it
' to finish, hiding while we wait.
Private Sub ShellAndWait(ByVal program_name As String, _
    ByVal window_style As VbAppWinStyle)
Dim process_id As Long
Dim process_handle As Long

    ' Start the program.
    On Error GoTo ShellError
    process_id = Shell(program_name, window_style)
    On Error GoTo 0

    ' Hide.
    Me.Visible = False
    DoEvents

    ' Wait for the program to finish.
    ' Get the process handle.
    process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
    If process_handle <> 0 Then
        WaitForSingleObject process_handle, INFINITE
        CloseHandle process_handle
    End If

    ' Reappear.
    Me.Visible = True
    Exit Sub

ShellError:
    MsgBox "Error starting task " & _
        program_name & vbCrLf & _
        Err.Description, vbOKOnly Or vbExclamation, _
        "Error"
End Sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 7

Expert Comment

by:jacobhoover
ID: 11947324
The only way to get the password is to have it in a .vnc file or to modify the code for the viewer itself.
0
 

Author Comment

by:DARKSAGES
ID: 11948108
where is the .vnc file located i dont see one?
0
 
LVL 7

Accepted Solution

by:
jacobhoover earned 2000 total points
ID: 11948143
Open up a viewer instance then right click on the menu, once connected, and click save connection info as...

It will create a text file similar to:
[connection]
host=<machine name here>
port=5900
password=<encoded password here>
[options]
use_encoding_0=1
use_encoding_1=1
use_encoding_2=1
use_encoding_3=0
use_encoding_4=1
use_encoding_5=1
use_encoding_6=1
use_encoding_7=1
use_encoding_8=1
preferred_encoding=7
restricted=0
viewonly=1
fullscreen=0
8bit=1
shared=1
swapmouse=0
belldeiconify=0
emulate3=1
emulate3timeout=100
emulate3fuzz=4
disableclipboard=0
localcursor=1
scale_den=1
scale_num=1
cursorshape=1
noremotecursor=0

So the obvious question is do you use static passwords or do they vary from machine to machine?  If they change you will have to find a means of encoding the pass into the correct format if you want to connect without having to enter it.

0
 

Author Comment

by:DARKSAGES
ID: 11948151
no the password is the same one for all machines
0
 

Author Comment

by:DARKSAGES
ID: 11948172
thanx
0
 
LVL 7

Expert Comment

by:jacobhoover
ID: 11948175
Also,
  the switches I listed are for TightVNC... Version 1.2.2.. There are numerious flavors of VNC available so there may be different switches available in the newer versions.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Six Sigma Control Plans
Introduction to Processes
Suggested Courses

801 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