Exemple #1
0
static BOOL test_EnumMonitors(struct torture_context *tctx,
			      LPSTR servername)
{
	DWORD levels[]  = { 1, 2 };
	DWORD success[] = { 1, 1 };
	DWORD i;
	LPBYTE buffer = NULL;

	for (i=0; i < ARRAY_SIZE(levels); i++) {

		DWORD needed = 0;
		DWORD returned = 0;
		DWORD err = 0;
		char tmp[1024];

		torture_comment(tctx, "Testing EnumMonitors level %d", levels[i]);

		EnumMonitors(servername, levels[i], NULL, 0, &needed, &returned);
		err = GetLastError();
		if (err == ERROR_INSUFFICIENT_BUFFER) {
			err = 0;
			buffer = malloc(needed);
			torture_assert(tctx, buffer, "malloc failed");
			if (!EnumMonitors(servername, levels[i], buffer, needed, &needed, &returned)) {
				err = GetLastError();
			}
		}
		if (err) {
			sprintf(tmp, "EnumMonitors failed level %d on [%s] (buffer size = %d), error: %s\n",
				levels[i], servername, needed, errstr(err));
			if (success[i]) {
				torture_fail(tctx, tmp);
			} else {
				torture_warning(tctx, tmp);
			}
		}

		free(buffer);
		buffer = NULL;
	}

	return TRUE;
}
Exemple #2
0
int PASCAL 
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow)
{
DWORD version = GetVersion();
   phInstance = hInstance;
   if ((HIWORD(version) & 0x8000)==0)
      is_winnt = TRUE;
   if (LOBYTE(LOWORD(version)) >= 4)
      is_win4 = TRUE;

   if (lstrlen(lpszCmdLine))
       silent = TRUE;

   LoadString(phInstance, IDS_TITLE, title, sizeof(title)/sizeof(TCHAR)-1);
   LoadString(phInstance, IDS_MONITORNAME, monitorname, 
	sizeof(monitorname)/sizeof(TCHAR)-1);

   /* Check that it really is installed */
   if (EnumMonitors(NULL, 1, (LPBYTE)buffer, sizeof(buffer), 
        &needed, &returned)) {
      MONITOR_INFO_1 *mi;
      mi = (MONITOR_INFO_1 *)buffer;
      for (i=0; i<returned; i++) {
	 if (lstrcmp(mi[i].pName, monitorname) == 0)
	    break;
      }
   }
   else
      return message(IDS_ENUMMONITORS_FAILED);

   if (i == returned)
	return message(IDS_NOT_INSTALLED);

   /* Warn user about what we are about to do */
   if (!silent) {
         TCHAR buf[256];
	 LoadString(phInstance, IDS_INTRO, buf, sizeof(buf)/sizeof(TCHAR)-1);
         if (MessageBox(HWND_DESKTOP, buf, title, MB_YESNO) != IDYES)
	     return 0;
   }

   /* Check if monitor is still in use */
   rc = EnumPorts(NULL, 2, (LPBYTE)buffer, sizeof(buffer), 
      &needed, &returned);
   pi2 = (PORT_INFO_2 *)buffer;
   if (rc) {
      for (i=0; i<returned; i++) {
	 if (lstrcmp(pi2[i].pMonitorName, monitorname) == 0) {
            TCHAR buf[256];
	    LoadString(phInstance, IDS_INUSE, buf, sizeof(buf)/sizeof(TCHAR)-1);
	    wsprintf(sysdir, buf, pi2[i].pPortName);
            MessageBox(HWND_DESKTOP, sysdir, title, MB_OK);
	    return 1;
	 }
      }
   }
   else
      return message(IDS_ENUMPORTS_FAILED);

   /* Try to delete the monitor */
   if (!DeleteMonitor(NULL,  
      NULL /* is_winnt ? MONITORENVNT : MONITORENV95 */, 
      monitorname))
	return message(IDS_DELETEMONITOR_FAILED);

   /* Delete the monitor files */
   if (!GetSystemDirectory(sysdir, sizeof(sysdir)))
	return message(IDS_NOSYSDIR);
   lstrcpy(buffer, sysdir);
   lstrcat(buffer, "\\");
   lstrcat(buffer, is_winnt ? MONITORDLLNT : MONITORDLL95);
   if (!DeleteFile(buffer))
	return message(IDS_ERROR_DELETE_DLL);
   lstrcpy(buffer, sysdir);
   lstrcat(buffer, "\\");
   lstrcat(buffer, MONITORHLP);
   if (!DeleteFile(buffer))
	return message(IDS_ERROR_DELETE_HELP);
   lstrcpy(buffer, sysdir);
   lstrcat(buffer, "\\");
   lstrcat(buffer, REDCONF);
   if (!DeleteFile(buffer))
       return message(IDS_ERROR_DELETE_REDCONF);

   /* delete registry entries for uninstall */
   if ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, UNINSTALLKEY, 0, 
	KEY_ALL_ACCESS, &hkey)) == ERROR_SUCCESS) {
	RegDeleteKey(hkey, MONITORKEY);
	RegCloseKey(hkey);
   }

   /* Delete this program, but we can't do it while we are running.
    * Defer deletion until next reboot
    */
   wsprintf(buffer, TEXT("%s\\%s"), sysdir, UNINSTALLPROG);
   if (is_winnt) {
        MoveFileEx(buffer, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
   }
   else {
	char ininame[256];
	GetWindowsDirectory(ininame, sizeof(ininame));
	lstrcat(ininame, "\\wininit.ini");
	/* This method is dodgy, because multiple applications
         * using this method to delete files will overwrite
         * earlier delete instructions.
         */
	WritePrivateProfileString("Rename", "NUL", buffer, ininame);
	SetLastError(0);
   }

#ifdef UNUSED
   /* We should delete this program, but we can't do it
    * while we are running.
    * I think there is a registry key we can create which says
    * "Delete these files on next reboot", but I can't find the 
    * documentation about it.
    * Instead, run a DOS window once to delete the file
    */
    if ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
	"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
	0, KEY_ALL_ACCESS, &hkey)) == ERROR_SUCCESS) {
	wsprintf(buffer, "command /c del %s\\%s", sysdir, UNINSTALLPROG);
	RegSetValueEx(hkey, MONITORKEY, 0, REG_SZ,
	    (CONST BYTE *)buffer, lstrlen(buffer)+1);
    }
#endif
   
   
   message(IDS_UNINSTALLED);

   return 0;
}
Exemple #3
0
BOOL
EnumGeneric(
    IN  PROC    fnEnum,
    IN  DWORD   Level,
    IN  PBYTE   *ppEnumData,
    IN  DWORD   cbBuf,
    OUT LPDWORD pcbReturned,
    OUT LPDWORD pcReturned,
    IN  PVOID   Arg1,
    IN  PVOID   Arg2,
    IN  PVOID   Arg3 )
{
    BOOL   rc;
    BOOL   UnknownFunction = FALSE;
    DWORD  cbRealloc;

    if( fnEnum == (PROC)EnumPrinters )
        rc = EnumPrinters( (DWORD)Arg1, (LPTSTR)Arg2, COMMON_ARGS );
                           // Flags        Name
    else if( fnEnum == (PROC)EnumJobs )
        rc = EnumJobs( (HANDLE)Arg1, (DWORD)Arg2, (DWORD)Arg3, COMMON_ARGS );
                       // hPrinter      FirstJob     NoJobs
    else if( fnEnum == (PROC)EnumPrinterDrivers )
        rc = EnumPrinterDrivers( (LPTSTR)Arg1, (LPTSTR)Arg2, COMMON_ARGS );
                                 // pName        pEnvironment
    else if( fnEnum == (PROC)EnumForms )
        rc = EnumForms( (HANDLE)Arg1, COMMON_ARGS );
                        // hPrinter
    else if( fnEnum == (PROC)EnumMonitors )
        rc = EnumMonitors( (LPTSTR)Arg1, COMMON_ARGS );
                           // pName
    else if( fnEnum == (PROC)EnumPorts )
        rc = EnumPorts( (LPTSTR)Arg1, COMMON_ARGS );
                        // pName
    else if( fnEnum == (PROC)EnumPrintProcessors )
        rc = EnumPrintProcessors( (LPTSTR)Arg1, (LPTSTR)Arg2, COMMON_ARGS );
                                  // pName        pEnvironment
    else if( fnEnum == (PROC)EnumPrintProcessorDatatypes )
        rc = EnumPrintProcessorDatatypes( (LPTSTR)Arg1, (LPTSTR)Arg2, COMMON_ARGS );
                                          // pName        pPrintProcessorName
    else
    {
        *ppEnumData = NULL;
        UnknownFunction = TRUE;

        DBGMSG( DBG_ERROR, ( "EnumGeneric called with unknown function\n" ) );

        rc = FALSE;
    }


    if( ( rc == FALSE ) && ( UnknownFunction == FALSE ) )
    {
        if( GetLastError( ) == ERROR_INSUFFICIENT_BUFFER )
        {
            cbRealloc = *pcbReturned;

            DBGMSG( DBG_TRACE, ( "EnumGeneric: Reallocating %d (0x%x) bytes @%08x\n",
                                 cbBuf, cbBuf, *ppEnumData ) );

            if( cbBuf == 0 )
                *ppEnumData = AllocSplMem( cbRealloc );
            else
                *ppEnumData = ReallocSplMem( *ppEnumData, cbRealloc );

            cbBuf = cbRealloc;

            if( *ppEnumData )
            {
                DBGMSG( DBG_TRACE, ( "EnumGeneric: %d (0x%x) bytes reallocated @%08x\n",
                                     cbBuf, cbBuf, *ppEnumData ) );

             if( fnEnum == (PROC)EnumPrinters )
                    rc = EnumPrinters( (DWORD)Arg1, (LPTSTR)Arg2, COMMON_ARGS );
                                       // Flags        Name
             else if( fnEnum == (PROC)EnumJobs )
                    rc = EnumJobs( (HANDLE)Arg1, (DWORD)Arg2, (DWORD)Arg3, COMMON_ARGS );
                                   // hPrinter      FirstJob     NoJobs
                else if( fnEnum == (PROC)EnumPrinterDrivers )
                    rc = EnumPrinterDrivers( (LPTSTR)Arg1, (LPTSTR)Arg2, COMMON_ARGS );
                                             // pName        pEnvironment
                else if( fnEnum == (PROC)EnumForms )
                    rc = EnumForms( (HANDLE)Arg1, COMMON_ARGS );
                                    // hPrinter
                else if( fnEnum == (PROC)EnumMonitors )
                    rc = EnumMonitors( (LPTSTR)Arg1, COMMON_ARGS );
                                       // pName
                else if( fnEnum == (PROC)EnumPorts )
                    rc = EnumPorts( (LPTSTR)Arg1, COMMON_ARGS );
                                    // pName
                else if( fnEnum == (PROC)EnumPrintProcessors )
                    rc = EnumPrintProcessors( (LPTSTR)Arg1, (LPTSTR)Arg2, COMMON_ARGS );
                                              // pName        pEnvironment
                else if( fnEnum == (PROC)EnumPrintProcessorDatatypes )
                    rc = EnumPrintProcessorDatatypes( (LPTSTR)Arg1, (LPTSTR)Arg2, COMMON_ARGS );
                                                      // pName        pPrintProcessorName

                /* If things haven't worked out, free up the buffer.
                 * We do this because otherwise the caller will not know
                 * whether the pointer is valid any more,
                 * since ReallocSplMem might have failed.
                 */
                if( rc == FALSE )
                {
                    if( *ppEnumData )
                        FreeSplMem( *ppEnumData );
                    *ppEnumData = NULL;
                    *pcbReturned = 0;
                    *pcReturned = 0;
                }

                /* Don't rely on pcbReturned having the same value
                 * that was passed in:
                 */
                else
                    *pcbReturned = cbRealloc;
            }
        }

        else
        {
            if( *ppEnumData )
                FreeSplMem( *ppEnumData );
            *ppEnumData = NULL;
            *pcbReturned = 0;
            *pcReturned = 0;
            rc = FALSE;
        }
    }

    else
        *pcbReturned = cbBuf;

    return rc;
}
Exemple #4
0
int main (int argc, char* argv[])
{
	
	DWORD			returned, needed, i;
	PMONITOR_INFO_1	buffer1 = NULL;
	PMONITOR_INFO_2	buffer2 = NULL;

	if (argc < 2)
	{
		fprintf (stderr, "useage: %s <servername>\n", argv[0]);
		exit (-1);
	}

	/* INFO LEVEL 1 */
	needed = returned = 0;
	EnumMonitors(argv[1], 1, (LPBYTE)buffer1, 0, &needed, &returned);
	if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
	{
		fprintf (stderr, "Error getting monitor information for [%s] using NULL buffer.\n", argv[1]);
		exit (-1);
	}

	if ((buffer1 = (LPBYTE)malloc(needed)) == NULL)
	{
		fprintf (stderr, "Unable to malloc memory for MONITOR_INFO_1 buffer!\n");
		exit (-1);
	}
	if (!EnumMonitors(argv[1], 1, (LPBYTE)buffer1, needed, &needed, &returned))
	{
		fprintf (stderr, "Error getting monitor information for [%s].\nSize of buffer = %d\n", 
			     argv[1], needed);
		exit (-1);
	}

	printf ("Monitor Info Level 1:\n");
	for (i=0; i<returned; i++)
	{
		print_monitor_info_1(&buffer1[i]);
	}
	free (buffer1);

	/* INFO LEVEL 2 */
	needed = returned = 0;
	EnumMonitors(argv[1], 2, (LPBYTE)buffer2, 0, &needed, &returned);
	if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
	{
		fprintf (stderr, "Error getting monitor information for [%s] using NULL buffer.\n", argv[1], argv[2]);
		exit (-1);
	}

	if ((buffer2 = (LPBYTE)malloc(needed)) == NULL)
	{
		fprintf (stderr, "Unable to malloc memory for MONITOR_INFO_2 buffer!\n");
		exit (-1);
	}
	if (!EnumMonitors(argv[1], 2, (LPBYTE)buffer2, needed, &needed, &returned))
	{
		fprintf (stderr, "Error getting monitor information for [%s].\nSize of buffer = %d\n", 
			     argv[1], needed);
		exit (-1);
	}

	printf ("Monitor Info Level 2:\n");
	for (i=0; i<returned; i++)
	{
		print_monitor_info_2(&buffer2[i]);
	}
	free (buffer2);


	return 0;

}
Exemple #5
0
/*
	createwindow().
	Creates a new window, _w * _h in size, optionally fullscreen.
*/
HWND CDisplayDX::createwindow( uint32 _w, uint32 _h, const bool _bFullscreen )
{
    m_bFullScreen = _bFullscreen;
    HMODULE    hInstance = GetModuleHandle(NULL);

    EnumMonitors();

    WNDCLASS   wndclass = {0};
    RECT       windowRect;
    SetRect( &windowRect, 0, 0, _w, _h );
    g_Log->Info( "CDisplayDX::createwindow x=%u y=%u w=%u h=%u", 0, 0, _w, _h);
    wndclass.style         = CS_HREDRAW | CS_VREDRAW;
    wndclass.lpfnWndProc   = (WNDPROC)CDisplayDX::wndProc;
    wndclass.cbClsExtra    = 0;
    wndclass.cbWndExtra    = 0;
    wndclass.hInstance     = hInstance;
    wndclass.hIcon         = LoadIcon (GetModuleHandle(NULL), MAKEINTRESOURCE(1));
    wndclass.hCursor       = NULL;//LoadCursor (NULL, IDC_ARROW);
    wndclass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
    wndclass.lpszMenuName  = NULL;
    wndclass.lpszClassName = L"ElectricsheepWndClass";

    static bool wndclassAlreadyRegistered = false;
    if( wndclassAlreadyRegistered == false && !RegisterClass (&wndclass) )
    {
        return 0;
    }
    wndclassAlreadyRegistered = true;

    /*if( _bFullscreen )
    {
    	DEVMODE dmScreenSettings;
    	memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
    	dmScreenSettings.dmSize = sizeof(dmScreenSettings);
    	dmScreenSettings.dmPelsWidth	= _w;
    	dmScreenSettings.dmPelsHeight	= _h;
    	dmScreenSettings.dmBitsPerPel	= 32;
    	dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

    	if( ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL )
    		OutputDebugString("Failed to change display settings");
    }*/

    unsigned long exStyle;
    unsigned long style;
    if( _bFullscreen )
    {
        exStyle = WS_EX_APPWINDOW | WS_EX_TOPMOST;
        style = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
    }
    else
    {
        exStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
        style =  WS_OVERLAPPEDWINDOW |
                 WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
    }

    AdjustWindowRectEx( &windowRect, style, false, exStyle );
    int ww = windowRect.right - windowRect.left;
    int hh = windowRect.bottom - windowRect.top;
    int xx = 0;
    int yy = 0;
    g_Log->Info( "CDisplayDX::createwindow AdjustWindowRectEx x=%u y=%u w=%u h=%u", 0, 0, ww, hh);
    MONITORINFO monitorInfo;

    for( DWORD iMonitor = 0; iMonitor < m_dwNumMonitors; iMonitor++ )
    {
        if (iMonitor == m_DesiredScreenID && _bFullscreen)
        {
            MonitorInfo *pMonitorInfo = &m_Monitors[iMonitor];
            monitorInfo.cbSize = sizeof(MONITORINFO);
            GetMonitorInfo( pMonitorInfo->hMonitor, &monitorInfo );
            pMonitorInfo->rcScreen = monitorInfo.rcMonitor;
            //SetWindowPos( hWnd, HWND_TOPMOST, monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top, SWP_NOACTIVATE );
            xx = monitorInfo.rcMonitor.left;
            yy = monitorInfo.rcMonitor.top;
            ww = monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left;
            hh = monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top;
            g_Log->Info( "CDisplayDX::createwindow SetWindowPos x=%u y=%u w=%u h=%u",  monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top);
        }
    }

    HWND hWnd = CreateWindowEx( exStyle, L"ElectricsheepWndClass", L"Electricsheep", style, xx, yy, ww, hh, NULL, NULL, hInstance, NULL );
    BlankUnusedMonitors(wndclass, hWnd, hInstance);
    return hWnd;
}
Exemple #6
0
int PASCAL 
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow)
{
DWORD version = GetVersion();
     phInstance = hInstance;
     if ((HIWORD(version) & 0x8000)==0)
	  is_winnt = TRUE;
     if (LOBYTE(LOWORD(version)) >= 4)
	  is_win4 = TRUE;

     if (lstrlen(lpszCmdLine))
	  silent = TRUE;

     LoadString(phInstance, IDS_TITLE, title, sizeof(title)/sizeof(TCHAR)-1);
     LoadString(phInstance, IDS_MONITORNAME, monitorname, 
	sizeof(monitorname)/sizeof(TCHAR)-1);

#ifdef BETA
     if (beta_warn())
	return 0;
#endif
     mi2.pName = monitorname;
     mi2.pEnvironment = is_winnt ? MONITORENVNT : MONITORENV95;
     mi2.pDLLName =     is_winnt ? MONITORDLLNT : MONITORDLL95 ;

     /* Check if already installed */
     if (EnumMonitors(NULL, 1, (LPBYTE)buffer, sizeof(buffer), 
	&needed, &returned)) {
	  mi = (MONITOR_INFO_1 *)buffer;
	  for (i=0; i<returned; i++) {
	  if (lstrcmp(mi[i].pName, monitorname) == 0)
	       return message(IDS_ALREADY_INSTALLED);
	   }
     }
     else
	  return message(IDS_ENUMMONITORS_FAILED);

     /* Warn user about what we are about to do */
     if (!silent) {
         TCHAR buf[256];
	 LoadString(phInstance, IDS_INTRO, buf, sizeof(buf)/sizeof(TCHAR)-1);
         if (MessageBox(HWND_DESKTOP, buf, title, MB_YESNO) != IDYES)
	     return 0;
     }

     /* copy files to Windows system directory */
     if (!GetSystemDirectory(sysdir, sizeof(sysdir)))
	  return message(IDS_NOSYSDIR);
     lstrcat(sysdir, "\\");

     /* get path to EXE */
     GetModuleFileName(hInstance, exepath, sizeof(exepath));
     if ((p = strrchr(exepath,'\\')) != (char *)NULL)
	  p++;
     else
	  p = exepath;
     *p = '\0';

     lstrcpy(destination, sysdir);
     lstrcat(destination, mi2.pDLLName);
     lstrcpy(source, exepath);
     lstrcat(source, mi2.pDLLName);
     if (!CopyFile(source, destination, FALSE))
	  return message(IDS_ERROR_COPY_DLL);
     lstrcpy(destination, sysdir);
     lstrcat(destination, MONITORHLP);
     lstrcpy(source, exepath);
     lstrcat(source, MONITORHLP);
     if (!CopyFile(source, destination, FALSE))
	  return message(IDS_ERROR_COPY_HELP);
     lstrcpy(destination, sysdir);
     lstrcat(destination, REDCONF);
     lstrcpy(source, exepath);
     lstrcat(source, REDCONF);
     if (!CopyFile(source, destination, FALSE))
         return message(IDS_ERROR_COPY_REDCONF);
     lstrcpy(destination, sysdir);
     lstrcat(destination, UNINSTALLPROG);
     lstrcpy(source, exepath);
     lstrcat(source, UNINSTALLPROG);
     if (!CopyFile(source, destination, FALSE))
	  return message(IDS_ERROR_COPY_UNINSTALL);

     if (!AddMonitor(NULL, 2, (LPBYTE)&mi2)) {
	  return message(IDS_ADDMONITOR_FAILED);
     }

     /* write registry entries for uninstall */
     if ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, UNINSTALLKEY, 0, 
	  KEY_ALL_ACCESS, &hkey)) != ERROR_SUCCESS) {
	/* failed to open key, so try to create it */
        rc = RegCreateKey(HKEY_LOCAL_MACHINE, UNINSTALLKEY, &hkey);
     }
     if (rc == ERROR_SUCCESS) {
	  if (RegCreateKey(hkey, MONITORKEY, &hsubkey) == ERROR_SUCCESS) {
	       lstrcpy(buffer, title);
	       RegSetValueEx(hsubkey, DISPLAYNAMEKEY, 0, REG_SZ,
		    (CONST BYTE *)buffer, lstrlen(buffer)+1);
	       lstrcpy(buffer, sysdir);
	       lstrcat(buffer, UNINSTALLPROG);
	       RegSetValueEx(hsubkey, UNINSTALLSTRINGKEY, 0, REG_SZ,
		    (CONST BYTE *)buffer, lstrlen(buffer)+1);
	       RegCloseKey(hsubkey);
	  }
	  RegCloseKey(hkey);
     }

     /* Disable removing of uninstall program, in case someone 
      * uninstalls then installs again without rebooting Windows.
      */
     wsprintf(source, TEXT("%s%s"), sysdir, UNINSTALLPROG);
     if (is_winnt) {
#define RENAME_KEY "PendingFileRenameOperations"
	 if ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
	    "SYSTEM\\CurrentControlSet\\Control\\Session Manager",
	    0, KEY_ALL_ACCESS, &hkey)) == ERROR_SUCCESS) {
	      DWORD dwType = REG_MULTI_SZ;
	      DWORD dwLength;
	      if ( (rc = RegQueryValueEx(hkey, RENAME_KEY, NULL, &dwType, 
		    buffer, &dwLength)) == ERROR_SUCCESS ) {
		/* look to see if unredmon.exe is mentioned */
		LPSTR p = buffer;
		LPSTR q;
		while (*p) {
		    q = p;
		    q += strlen(q) + 1;	/* skip existing name */
		    q += strlen(q) + 1;	/* skip new name */
		    if (lstrcmp(p, source) == 0) {
			MoveMemory(p, q, dwLength - (q - buffer));
			dwLength -= (q-p);
		    }
		    else
			p = q;
		}
		RegSetValueEx(hkey, RENAME_KEY, 0, dwType, 
		    buffer, dwLength); 
	      }
	 }
#undef RENAME_KEY
     }
     else {
	char ini_name[256];
	GetWindowsDirectory(ini_name, sizeof(ini_name));
	lstrcat(ini_name, "\\wininit.ini");
	GetPrivateProfileString("Rename", "NUL", "", 
	    buffer, sizeof(buffer), ini_name);
	if (lstrcmp(source, buffer) == 0) {
	    WritePrivateProfileString("Rename", "NUL", NULL, ini_name);
	}
	SetLastError(0);
     }

#ifdef UNUSED
     if ((rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
	"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
	0, KEY_ALL_ACCESS, &hkey)) == ERROR_SUCCESS) {
	  RegDeleteValue(hkey, MONITORKEY);
     }
#endif

     message(IDS_INSTALL_OK);

     return 0;
}