using URL protocol handlers in windows

Jason Ellison infotek@datasync.com
Fri Oct 17 12:14:02 2003


 Maybe someone will find this useful. It was tested on 3.3.7 windows x86
source. I used MS Visual C++ 6.0 to compile the source.

Explaination
  Enabling the windows to use vnc applications to handle a particular
(vnc: and vncv:) URL protocol. You must add support to windows to
understand the URL's. The following registry information needs to me
imported. Winvnc and vncviewer must also be modified to compensate for the
vnc: and vncv: prefixes that will get passed to the programs.


URL Test
  Adds client to an existing VNC Server. Or connects the local VNC Server
to a remote vncviewer in listen mode. This a remote control session
initiated by the client. 

<a href="vnc:hostname">vnc:hostname</a>

  Connects to a remote VNC Server by calling vncviewer. 

<a href="vncv:hostname">vncv:hostname</a>


FILES and MODIFICATIONS

vnc_URLs.reg 

REGEDIT4

[HKEY_CLASSES_ROOT\vnc]
@="URL:VNC Protocol"
"URL Protocol"="http://www.realvnc.com/"

[HKEY_CLASSES_ROOT\vnc\DefaultIcon]
@="C:\\Program Files\\RealVNC\\WinVNC\\winvnc.exe,0"

[HKEY_CLASSES_ROOT\vnc\shell]

[HKEY_CLASSES_ROOT\vnc\shell\open]

[HKEY_CLASSES_ROOT\vnc\shell\open\command]
@="C:\\Program Files\\RealVNC\\WinVNC\\winvnc.exe -connect %1"

[HKEY_CLASSES_ROOT\vncv]
@="URL:VNC Viewer Protocol"
"URL Protocol"="http://www.realvnc.com/"

[HKEY_CLASSES_ROOT\vncv\DefaultIcon]
@="C:\\Program Files\\RealVNC\\vncviewer.exe,0"

[HKEY_CLASSES_ROOT\vncv\shell]

[HKEY_CLASSES_ROOT\vncv\shell\open]

[HKEY_CLASSES_ROOT\vncv\shell\open\command]
@="C:\\Program Files\\RealVNC\\vncviewer.exe %1"


  The following are the modifications made to winvnc version 3.3.7. 

//add vnc: and vncv: comprehension to winvnc commandline

////winvnc\winvnc\vsocket.cpp:366


VSocket::Resolve(const VString address)
{
  VCard32 addr;

  //BEGIN Check for vnc:
  //if found ignore to accomidate protocol handlers passed by commandline
  //bobby.j.peebles@delphi.com
  //jason.l.ellison@delphi.com
  char mtemp[256]; 
  sprintf (mtemp,"%s",address); 
  if (!strncmp(mtemp,"vnc:", 4)) 
  { 
    sprintf( address, "%s", mtemp +4 ); 
  }
  //END Check for vnc:
  // Try converting the address as IP
  addr = inet_addr(address);


////vncviewer\vncviewer.cpp:122

bool ParseDisplay(LPTSTR display, LPTSTR phost, int hostlen, int *pport) 
{
    //BEGIN Check for vncv:
    //if found ignore to accomidate protocol handlers passed by
commandline
    //bobby.j.peebles@delphi.com
    //jason.l.ellison@delphi.com
    char mtemp[256]; 
    sprintf (mtemp,"%s", display); 
    if (!strncmp(mtemp, "vncv:", 5)) 
    { 
      sprintf(display, "%s", mtemp +5 ); 
    }
    //END Check for vncv:
    int tmpport;