Solved

vncviewer.exe in vb app

Posted on 2004-08-31
9
693 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wordlen challenge 3 66
Help to convert powershell script into a gui 9 169
SQL Insert parts by customer 12 31
What does != "" mean in programming 7 23
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

813 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

17 Experts available now in Live!

Get 1:1 Help Now