Solved

vncviewer.exe in vb app

Posted on 2004-08-31
9
689 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
  • 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
 
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
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

 

Author Comment

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

Accepted Solution

by:
jacobhoover earned 500 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoresIncreasing challenge 10 57
matchUp  challenge 9 72
nestparen challenge 4 57
Modify a small python script 19 56
This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

744 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

10 Experts available now in Live!

Get 1:1 Help Now