Starting WinVNC with -connect option?

Brandon Ibach bibach "at" infomansol.com
Wed, 15 Mar 2000 05:34:32 +0000


--VbJkn9YxBvnuCH5J
Content-Type: text/plain; charset=us-ascii

Quoting Andrew Kincaid <akincaid "at" gsu.edu>:
> Both of them continue on with the rest of the script instead of
> waiting for me to close WinVNC before continuing.   Is there anyway
> I can call WinVNC and the "-connect" option with one call?  (Again,
> "start /wait winvnc -connect MACHINE_NAME" construct would be
> super!)
> 
   Here's a quickly-hacked-together patch against WinVNC 3.3.3r2.  It
adds a new option, -connectrun, which is identical to the existing
-connect option, except that it doesn't try to contact an existing
instance of WinVNC, but rather starts a new instance and passes it a
message to connect right away.
   This has *NOT* been tested in any way.  I don't even have the tools
to compile WinVNC.  But, if it does work as it should, then try:

	start /wait winvnc -connectrun MACHINE_NAME

   Let me know if this works... :)

-Brandon :)

--VbJkn9YxBvnuCH5J
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="connectrun.patch"

diff -C 2 winvnc/WinVNC.cpp winvnc-2/WinVNC.cpp
*** winvnc/WinVNC.cpp	Tue Mar 14 22:52:43 2000
--- winvnc-2/WinVNC.cpp	Tue Mar 14 23:14:20 2000
***************
*** 157,162 ****
--- 157,167 ----
  		if (strncmp(&szCmdLine[i], winvncAddNewClient, strlen(winvncAddNewClient)) == 0)
  		{
+ 			BOOL runtoo = FALSE;
  			// Add a new client to an existing copy of winvnc
  			i+=strlen(winvncAddNewClient);
+ 			if (strncmp(&szCmdLine[i], winvncRunNewClient, strlen(winvncRunNewClient)) == 0) {
+ 				runtoo = TRUE;
+ 				i+=strlen(winvncRunNewClient);
+ 			}
  
  			// First, we have to parse the command line to get the filename to use
***************
*** 174,182 ****
  					name[end-start] = 0;
  					VCard32 address = VSocket::Resolve(name);
  					if (address != 0) {
  						// Post the IP address to the server
  						vncService::PostAddNewClient(address);
  					}
- 					delete [] name;
  				}
  				i=end;
--- 179,189 ----
  					name[end-start] = 0;
  					VCard32 address = VSocket::Resolve(name);
+ 					delete [] name;
  					if (address != 0) {
  						// Post the IP address to the server
+ 						if (runtoo)
+ 							return WinVNCAppMain(address);
  						vncService::PostAddNewClient(address);
  					}
  				}
  				i=end;
***************
*** 206,209 ****
--- 213,221 ----
  int WinVNCAppMain()
  {
+ 	return WinVNCAppMain(0);
+ }
+ 
+ int WinVNCAppMain(VCard32 addr)
+ {
  	// Set this process to be the last application to be shut down.
  	SetProcessShutdownParameters(0x100, 0);
***************
*** 232,235 ****
--- 244,251 ----
  		PostQuitMessage(0);
  	}
+ 
+ 	// Add new client, if an address was provided by -connectrun
+ 	if (addr != 0)
+ 		PostMessage(menu->hwnd(), MENU_ADD_CLIENT_MSG, 0, address);
  
  	// Now enter the message handling loop until told to quit!
diff -C 2 winvnc/WinVNC.h winvnc-2/WinVNC.h
*** winvnc/WinVNC.h	Tue Mar 14 22:56:27 2000
--- winvnc-2/WinVNC.h	Tue Mar 14 23:00:21 2000
***************
*** 60,63 ****
--- 60,64 ----
  
  const char winvncAddNewClient[]		= "-connect";
+ const char winvncRunNewClient[]		= "-connectrun";
  
  const char winvncShowHelp[]			= "-help";
diff -C 2 winvnc/vncMenu.h winvnc-2/vncMenu.h
*** winvnc/vncMenu.h	Tue Mar 14 23:12:15 2000
--- winvnc-2/vncMenu.h	Tue Mar 14 23:13:23 2000
***************
*** 52,55 ****
--- 52,56 ----
  	vncMenu(vncServer *server);
  	~vncMenu();
+ 	HWND hwnd() {return m_hwnd;};
  protected:
  	// Tray icon handling

--VbJkn9YxBvnuCH5J--

---------------------------------------------------------------------
To unsubscribe, send a message with the line: unsubscribe vnc-list
to majordomo "at" uk.research.att.com
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------