예제 #1
0
CString CRegistry::GetString(LPCTSTR pszSection, LPCTSTR pszName, LPCTSTR pszDefault, LPCTSTR pszSubKey, BOOL bIgnoreHKCU)
{
	CString strSection( pszSubKey ? pszSubKey : _T("Software\\PeerProject\\PeerProject") );
	if ( pszSection && *pszSection )
	{
		if ( pszSection[0] != _T('\\') )
			strSection += _T("\\");
		strSection += pszSection;
	}

	// Read from HKCU then from HKLM
	DWORD nType = 0, nSize = 0;
	LONG nErrorCode = SHRegGetUSValue( (LPCTSTR)strSection, pszName, &nType,
		NULL, &nSize, bIgnoreHKCU, NULL, 0 );
	if ( nErrorCode == ERROR_SUCCESS && nType == REG_SZ && nSize >= sizeof( TCHAR ) && ( nSize & 1 ) == 0 )
	{
		CString strValue;
		nErrorCode = SHRegGetUSValue( (LPCTSTR)strSection, pszName, &nType,
			strValue.GetBuffer( nSize / sizeof( TCHAR ) ), &nSize, bIgnoreHKCU, NULL, 0 );
		strValue.ReleaseBuffer( nSize / sizeof( TCHAR ) - 1 );
		if ( nErrorCode == ERROR_SUCCESS )
			return strValue;
	}

	return pszDefault ? CString( pszDefault ) : CString();
}
예제 #2
0
DWORD CRegistry::GetDword(LPCTSTR pszSection, LPCTSTR pszName, DWORD nDefault, LPCTSTR pszSubKey)
{
	CString strSection( pszSubKey ? pszSubKey : _T("Software\\PeerProject\\PeerProject") );
	if ( pszSection && *pszSection )
	{
		if ( pszSection[0] != _T('\\') )
			strSection += _T("\\");
		strSection += pszSection;
	}

	// Read from HKCU then from HKLM
	DWORD nValue = 0;
	DWORD nType = 0, nSize = sizeof( nValue );
	LONG nErrorCode = SHRegGetUSValue( (LPCTSTR)strSection, pszName, &nType,
		(PBYTE)&nValue, &nSize, FALSE, NULL, 0 );
	if ( nErrorCode == ERROR_SUCCESS && nType == REG_DWORD && nSize == sizeof( nValue ) )
		return nValue;

	return nDefault;
}
예제 #3
0
static void
init_gag(GaimConnection *gc)
{
  char sanity_check_buffer[8];
  int sane;
#ifdef NO_FORK
  char gag_path[256];
  DWORD gag_path_size = 240;
#endif

  gaim_debug(GAIM_DEBUG_INFO,"sippy","Initializing Gag\n");  

#ifdef NO_FORK
  {
    int listenfd;
    int status;
    int shell_exec_status;
    struct sockaddr_in us;
    struct sockaddr_in them;
    size_t addr_len = sizeof(them);
    char buffer[1024];

    memset((void *)&us, 0, sizeof(struct sockaddr_in));
    memset((void *)&them, 0, sizeof(struct sockaddr_in));
    us.sin_family = AF_INET;
    us.sin_port = 0xBEEF;
    inet_aton("127.0.0.1", &(us.sin_addr));

    listenfd = socket(PF_INET, SOCK_STREAM, 0);
    if (listenfd < 0)
    {
      /* We're single threaded, so strerror is safe */
      snprintf(buffer, sizeof(buffer), 
               "Unable to start the SIP engine - "
               "Could not create loopback socket; err = %d (%s)",
               errno, strerror(errno));

      gaim_connection_error(gc, buffer);
      return;
    }

    status = bind (listenfd, (struct sockaddr*)&us, sizeof(struct sockaddr));
    if (status != 0)
    {
      /* We're single threaded, so strerror is safe */
      snprintf(buffer, sizeof(buffer), 
               "Unable to start the SIP engine - "
               "Could not bind to loopback socket; err = %d (%s)",
               errno, strerror(errno));

      gaim_connection_error(gc, buffer);
      return;
    }
 
    status = listen(listenfd, 1);
    if (status != 0)
    {
      /* We're single threaded, so strerror is safe */
      snprintf(buffer, sizeof(buffer), 
               "Unable to start the SIP engine - "
               "Could not listen on loopback socket; err = %d (%s)",
               errno, strerror(errno));

      gaim_connection_error(gc, buffer);
      return;
    }

    /* Start SIP engine */

    /* First, check in the directory into which Gaim is installed */
    SHRegGetUSValue ("SOFTWARE\\gaim", NULL, NULL, 
                     (LPVOID)gag_path, 
                     &gag_path_size, 
                     TRUE,
                     NULL, 0);
    strcat(gag_path, "\\gag.exe");

    shell_exec_status = 
      (int)ShellExecute(NULL, "open", gag_path, "-l", NULL, 0);

    /* If that fails, see if it's in the path somewhere. */
    if (shell_exec_status <= 32)
    {
      shell_exec_status = 
        (int)ShellExecute(NULL, "open", "gag.exe", "-l", NULL, 0);
    }

    /* Well, if we can't find the gag.exe binary, we can't continue. */
    if (shell_exec_status <= 32)
    {
      gaim_connection_error(gc,
         _("Unable to start the SIP engine - gag.exe is not in your path"));
      close(listenfd);
      return;
    }

    gagfd = accept(listenfd, (struct sockaddr *)&them, &addr_len);
    if (gagfd < 0)
    {
      gaim_connection_error(gc,
         _("Unable to start the SIP engine - "
           "Could not accept incoming loopback connection"));
      close(listenfd);
      return;
    }

    close (listenfd);
  }
#else
  {
    int fork_result;

    if ( (pipe(gaimtogag)!=0) || (pipe(gagtogaim)!=0) )
    {
      gaim_connection_error(gc,
         _("Unable to start the SIP engine - resources unavailable"));
      return;
    }
    
    if ( (fork_result = fork()) == -1 )
    {
      gaim_connection_error(gc,
         _("Unable to start the SIP engine - process unavailable"));
      return;
    }
 
    if (fork_result == 0)
    {
      /* We are the child
         Read from gaim using gaimtogag[0]
         Write to gaim using gagtogaim[1]
      */

      close(0);
      close(1);

      dup(gaimtogag[0]);  /* new 0 */
      close(gaimtogag[0]);
      close(gaimtogag[1]);

      dup(gagtogaim[1]);  /* new 1 */
      close(gagtogaim[0]);
      close(gagtogaim[1]);
    
      execlp("gag","gag", (char*)0);

      /* if we're here, exec went horribly wrong */
      { 
        int t,l;
        char v;
        t=2; l=1; v=0;
        write (1,(void *)&t,sizeof(int));
        write (1,(void *)&l,sizeof(int));
        write (1,(void *)&v,1);
      }
      _exit(-1);
    }
  }
#endif

  /* In the parent
     Read from gag using FD_GAG_TO_GAIM
     Write to gag using FD_GAIM_TO_GAG
  */
    
  gaim_debug(GAIM_DEBUG_INFO,"sippy","starting sanity check\n");  
  sane = 1;
  read(FD_GAG_TO_GAIM,sanity_check_buffer,sizeof(int));
  sane = (*((int*)sanity_check_buffer)==2);
  if (sane) {
    read(FD_GAG_TO_GAIM,sanity_check_buffer,sizeof(int));
    sane = (*((int*)sanity_check_buffer)==1);
  }
  if (sane) {
    read(FD_GAG_TO_GAIM,sanity_check_buffer,1);
    sane = ((*sanity_check_buffer)!=0x00);
  }
  
  if (!sane)
  {
    return;
  }

  gaim_debug(GAIM_DEBUG_INFO,"sippy","gag is sane\n");  

  gaginitialized = 1;
}
예제 #4
0
/* static */
void VSTEffect::Scan()
{
   wxArrayString audacityPathList = wxGetApp().audacityPathList;
   wxArrayString pathList;
   wxArrayString files;

   // Check for the VST_PATH environment variable
   wxString vstpath = wxGetenv(wxT("VST_PATH"));
   if (!vstpath.IsEmpty()) {
      wxGetApp().AddUniquePathToPathList(vstpath, pathList);
   }

   // Add Audacity specific paths
   for (size_t i = 0; i < audacityPathList.GetCount(); i++) {
      wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH;
      wxGetApp().AddUniquePathToPathList(prefix + VSTPLUGINTYPE,
                                         pathList);
      wxGetApp().AddUniquePathToPathList(prefix + wxT("plugins"),
                                         pathList);
      wxGetApp().AddUniquePathToPathList(prefix + wxT("plug-ins"),
                                         pathList);
   }

#if defined(__WXMAC__)
#define VSTPATH wxT("/Library/Audio/Plug-Ins/VST")

   // Look in /Library/Audio/Plug-Ins/VST and $HOME/Library/Audio/Plug-Ins/VST
   wxGetApp().AddUniquePathToPathList(VSTPATH, pathList);
   wxGetApp().AddUniquePathToPathList(wxString(wxGetenv(wxT("HOME"))) + VSTPATH,
                                      pathList);

   // Recursively search all paths for Info.plist files.  This will identify all
   // bundles.
   wxGetApp().FindFilesInPathList(wxT("Info.plist"), pathList, files, wxDIR_DEFAULT);

   // Remove the 'Contents/Info.plist' portion of the names
   for (size_t i = 0, cnt = files.GetCount(); i < cnt; i++) {
      files[i] = wxPathOnly(wxPathOnly(files[i]));
   }
   
#elif defined(__WXMSW__)
   TCHAR dpath[MAX_PATH];
   TCHAR tpath[MAX_PATH];
   DWORD len = WXSIZEOF(tpath);

   // Setup the default VST path.
   dpath[0] = '\0';
   ExpandEnvironmentStrings(wxT("%ProgramFiles%\\Steinberg\\VSTPlugins"),
                            dpath,
                            WXSIZEOF(dpath));

   // Check registry for the real path
   if (SHRegGetUSValue(wxT("Software\\VST"),
                          wxT("VSTPluginsPath"),
                          NULL,
                          tpath,
                          &len,
                          FALSE,
                          dpath,
                          (DWORD) _tcslen(dpath)) == ERROR_SUCCESS) {
      tpath[len] = 0;
      ExpandEnvironmentStrings(tpath, dpath, WXSIZEOF(dpath));
      wxGetApp().AddUniquePathToPathList(LAT1CTOWX(dpath), pathList);
   }

   // Recursively scan for all DLLs
   wxGetApp().FindFilesInPathList(wxT("*.dll"), pathList, files, wxDIR_DEFAULT);

#else

   // Recursively scan for all shared objects
   wxGetApp().FindFilesInPathList(wxT("*.so"), pathList, files);

#endif

   // This is a hack to allow for long paths in the progress dialog.  The
   // progress dialog should really truncate the message if it's too wide
   // for the dialog.
   size_t cnt = files.GetCount();
   wxString longest;

   // JKC: Let's not show the progress dialog if there are no 
   // files to test.
   if( cnt <= 0 )
      return;

   for (size_t i = 0; i < cnt; i++) {
      if (files[i].Length() > longest.Length()) {
         longest = files[i];
      }
   }

   ProgressDialog *progress = new ProgressDialog(_("Scanning VST Plugins"),
                                                 longest,
                                                 pdlgHideStopButton);
//   progress->SetSize(wxSize(500, -1));
   progress->CenterOnScreen();

   const wxChar * argv[4];
   argv[0] = PlatformCompatibility::GetExecutablePath().c_str();
   argv[1] = VSTCMDKEY;
   argv[2] = NULL;
   argv[3] = NULL;

   for (size_t i = 0; i < cnt; i++) {
      wxString file = files[i];
      int status = progress->Update(wxLongLong(i),
                                    wxLongLong(cnt),
                                    wxString::Format(_("Checking %s"), file.c_str()));
      if (status != eProgressSuccess) {
         break;
      }

      argv[2] = file.c_str();
      // ToDo: do we need a try--catch around this in case a bad plug-in 
      // fails? (JKC Nov09)
      wxExecute((wxChar **) argv, wxEXEC_SYNC | wxEXEC_NODISABLE, NULL);
   }

   delete progress;   
}
예제 #5
0
void CALLBACK ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
{
	TCHAR szTmp[8192];
	char szTmpA[8192];
	TCHAR szTmp2[8192];
	char szAuthServer[32];
	DWORD dwTmp,dwType;
	HKEY hk;
	int seq=1,err;
	LPCSTR szNode;
	addrinfo *pAddrInfo;

	if(dwArgc!=999)
	{
		if (!(g_hService = RegisterServiceCtrlHandler(SERVICE_NAME,ServiceHandler))) { ReportError(TRUE,"Unable to start "SERVICE_NAMEA" - RegisterServiceCtrlHandler failed"); return; }
		NotifySCM(SERVICE_START_PENDING, 0, seq++);
	}
	else
	{
		g_bTestMode=TRUE;
		printf(SERVICE_NAMEA" " CVSNT_PRODUCTVERSION_STRING " ("__DATE__") starting in test mode.\n");
	}

	if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"),NULL,KEY_QUERY_VALUE,&hk))
	{ 
		ReportError(TRUE,"Unable to start "SERVICE_NAMEA" - Couldn't open environment key"); 
		if(!g_bTestMode)
			NotifySCM(SERVICE_STOPPED,0,0);
		return;
	}

	dwTmp=sizeof(szTmp);
	if(RegQueryValueEx(hk,_T("PATH"),NULL,&dwType,(BYTE*)szTmp,&dwTmp))
	{
		ReportError(TRUE,"Unable to start "SERVICE_NAMEA" - PATH environment variable not defined in system environment");
		if(!g_bTestMode)
			NotifySCM(SERVICE_STOPPED,0,0);
		return;
	}
	ExpandEnvironmentStrings(szTmp,szTmp2,sizeof(szTmp));
	SetEnvironmentVariable(_T("PATH"),szTmp2);

	RegCloseKey(hk);

	if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("Software\\CVS\\Pserver"),NULL,KEY_QUERY_VALUE,&hk))
	{
		ReportError(TRUE,"Unable to start "SERVICE_NAMEA" - Couldn't open HKLM\\Software\\CVS\\Pserver key");
		if(!g_bTestMode)
			NotifySCM(SERVICE_STOPPED,0,0);
		return;
	}

	dwTmp=sizeof(szTmp);
	if(RegQueryValueEx(hk,_T("TempDir"),NULL,&dwType,(LPBYTE)szTmp,&dwTmp) &&
	   SHRegGetUSValue(_T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"),_T("TEMP"),NULL,(LPVOID)szTmp,&dwTmp,TRUE,NULL,0) &&
	   !GetEnvironmentVariable(_T("TEMP"),(LPTSTR)szTmp,sizeof(szTmp)) &&
	   !GetEnvironmentVariable(_T("TMP"),(LPTSTR)szTmp,sizeof(szTmp)))
	{
		_tcscpy(szTmp,_T("C:\\"));
	}

	SetEnvironmentVariable(_T("TEMP"),szTmp);
	SetEnvironmentVariable(_T("TMP"),szTmp);
	if(g_bTestMode)
		_tprintf(_T("TEMP/TMP currently set to %s\n"),szTmp);

	dwTmp=sizeof(DWORD);
	if(!RegQueryValueEx(hk,_T("PServerPort"),NULL,&dwType,(BYTE*)szTmp,&dwTmp))
	{
		authserver_port=*(DWORD*)szTmp;
	}
	itoa(authserver_port,szAuthServer,10);

// Initialisation
    WSADATA data;

    if(WSAStartup (MAKEWORD (1, 1), &data))
	{
		ReportError(TRUE,"WSAStartup failed... aborting - Error %d\n",WSAGetLastError());
		if(!g_bTestMode)
			NotifySCM(SERVICE_STOPPED,0,0);
		return;
	}

	dwTmp=sizeof(szTmpA);
	szNode = NULL;
	if(!RegQueryValueExA(hk,"BindAddress",NULL,&dwType,(BYTE*)szTmpA,&dwTmp))
	{
		if(stricmp(szTmpA,"*"))
			szNode = szTmpA;
	}

	addrinfo hint = {0};
	hint.ai_family=PF_UNSPEC;
	hint.ai_socktype=SOCK_STREAM;
	hint.ai_protocol=IPPROTO_TCP;
	hint.ai_flags=AI_PASSIVE;
	pAddrInfo=NULL;
	if(g_bTestMode)
	{
		printf("Initialising socket...");
	}
	err=getaddrinfo(szNode,szAuthServer,&hint,&pAddrInfo);
	if(g_bTestMode)
	{
		if(err)
			printf("failed (%s)\n",gai_strerror(err));
		else
		{
			if(!pAddrInfo)
			{
				printf("This server doesn't know how to bind tcp sockets!!!  Your sockets layer is broken!!!\n");
			}
			else
				printf("ok\n");
		}
	}
	if(err)
		ReportError(FALSE,"Failed to get ipv4 socket details: %s",gai_strerror(err));

	RegCloseKey(hk);

	if(!g_bTestMode)
		NotifySCM(SERVICE_START_PENDING, 0, seq++);

	int impersonate=1;
	if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("Software\\CVS\\Pserver"),0,KEY_QUERY_VALUE,&hk))
	{
		DWORD dwType,dwImpersonate;
		DWORD dwTmp=sizeof(dwTmp);
		if(!RegQueryValueEx(hk,_T("Impersonation"),NULL,&dwType,(BYTE*)&dwImpersonate,&dwTmp))
			impersonate = dwImpersonate;
        RegCloseKey(hk);
        hk = 0;
	
	}
	if(impersonate)
		printf("Impersonation is enabled\n");
	else
		printf("*WARNING* Impersonation is disabled - all file access will be done as System user\n");

	if(g_bTestMode)
		printf("Starting auth server on port %d/tcp...\n",authserver_port);

	addrinfo* ai;
	for(ai=pAddrInfo;ai;ai=ai->ai_next)
	{
		SOCKET s = WSASocket(ai->ai_family,ai->ai_socktype,ai->ai_protocol,NULL,0,0);

		if(s!=-1 && !bind(s,ai->ai_addr,ai->ai_addrlen))
		{
			if(listen(s,50)==SOCKET_ERROR)
			{
				ReportError(TRUE,"Listen on socket failed: %s\n",gai_strerror(WSAGetLastError()));
				if(!g_bTestMode)
					NotifySCM(SERVICE_STOPPED,0,0);
				freeaddrinfo(pAddrInfo);
				return;
			} 
			g_Sockets.push_back(s);
		}
		else
		{
			if(g_bTestMode)
				printf("Socket Failed (Handle=%08x Family=%d,Socktype=%d,Protocol=%d): %s (not fatal)\n",s,ai->ai_family,ai->ai_socktype,ai->ai_protocol, gai_strerror(WSAGetLastError()));
			closesocket(s);
		}
	}
	freeaddrinfo(pAddrInfo);

	if(!g_Sockets.size())
	{
		ReportError(TRUE,"All socket binds failed.");
		if(!g_bTestMode)
			NotifySCM(SERVICE_STOPPED,0,0);
		return;
	}

	DWORD (WINAPI *pDsServerRegisterSpn)(DS_SPN_WRITE_OP Operation, LPCTSTR ServiceClass, LPCTSTR UserObjectDN);

    UINT oldMode=SetErrorMode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS);
	pDsServerRegisterSpn = (DWORD (WINAPI*)(DS_SPN_WRITE_OP,LPCTSTR,LPCTSTR))GetProcAddress(LoadLibrary("ntdsapi.dll"),"DsServerRegisterSpnA");
	SetErrorMode(oldMode);
	if(pDsServerRegisterSpn)
	{
		if(g_bTestMode)
			printf("Registering service SPN... ");
		pDsServerRegisterSpn(DS_SPN_DELETE_SPN_OP,"cvs",NULL);
		if(!g_bTestMode)
			NotifySCM(SERVICE_START_PENDING, 0, seq++);
		pDsServerRegisterSpn(DS_SPN_DELETE_SPN_OP,"cvs",NULL);
		if(!g_bTestMode)
			NotifySCM(SERVICE_START_PENDING, 0, seq++);
		if((dwTmp=pDsServerRegisterSpn(DS_SPN_ADD_SPN_OP,"cvs",NULL))!=0)
		{
			if(g_bTestMode)
				printf("failed (Error %d)\n",dwTmp);
			//ReportError(TRUE,"Registering cvs service SPN failed (error %d)", dwTmp);
		}
		else
		{
			if(g_bTestMode)
				printf("ok\n");
		}
	}

	// Process running, wait for closedown
	ReportError(FALSE,SERVICE_NAMEA" initialised successfully");
	if(!g_bTestMode)
		NotifySCM(SERVICE_RUNNING, 0, 0);

	g_bStop=FALSE;

	do
	{
		fd_set rfd;
		sockaddr_storage sin;
		size_t n;

		FD_ZERO(&rfd);
		for(n=0; n<g_Sockets.size(); n++)
			FD_SET(g_Sockets[n],&rfd);
		TIMEVAL tv = { 5, 0 }; // 5 seconds max wait
		int sel=select(1,&rfd,NULL,NULL,&tv);
		if(g_bStop || sel==SOCKET_ERROR) break; // Error on socket, or stopped
		for(n=0; n<g_Sockets.size(); n++)
		{
			if(FD_ISSET(g_Sockets[n],&rfd))
			{
				HANDLE hConn=(HANDLE)accept(g_Sockets[n],(struct sockaddr*)&sin,NULL);
				CloseHandle(CreateThread(NULL,0,DoCvsThread,(void*)hConn,0,NULL));
			}
		}
	} while(!g_bStop);

	if(pDsServerRegisterSpn)
	{
		if(g_bTestMode)
			printf("Unregistering service SPN...\n");
		pDsServerRegisterSpn(DS_SPN_DELETE_SPN_OP,"cvs",NULL);
	}
	NotifySCM(SERVICE_STOPPED, 0, 0);
	ReportError(FALSE,SERVICE_NAMEA" stopped successfully");
}
예제 #6
0
파일: settingspage.cpp 프로젝트: acml/cvsnt
BOOL CSettingsPage::OnInitDialog()
{
	int t;
	BYTE buf[_MAX_PATH*sizeof(TCHAR)];
	DWORD bufLen;
	DWORD dwType;
	CWaitCursor wait;

	CTooltipPropertyPage::OnInitDialog();

	SetDlgItemInt(IDC_PSERVERPORT,(t=QueryDword(_T("PServerPort")))>=0?t:2401,FALSE);
	bufLen=sizeof(buf);
	if(RegQueryValueEx(g_hServerKey,_T("LockServer"),NULL,&dwType,buf,&bufLen))
	{
		SetDlgItemText(IDC_LOCKSERVER,_T("localhost"));
		SetDlgItemInt(IDC_LOCKSERVERPORT,(t=QueryDword(_T("LockServerPort")))>=0?t:2402,FALSE);
	}
	else
	{
		RegDeleteValue(g_hServerKey,_T("LockServerPort"));
		TCHAR *p=_tcschr((TCHAR*)buf,':');
		if(p)
			*p='\0';
		m_edLockServer.SetWindowText((LPCTSTR)buf);
		SetDlgItemInt(IDC_LOCKSERVERPORT,p?_tstoi(p+1):2402,FALSE);
	}

	if(!RegQueryValueEx(g_hServerKey,_T("AnonymousUsername"),NULL,&dwType,buf,&bufLen))
		m_edAnonUser.SetWindowText((TCHAR*)buf);

	SendDlgItemMessage(IDC_PSERVERPORT,EM_LIMITTEXT,4);
	SendDlgItemMessage(IDC_LOCKSERVERPORT,EM_LIMITTEXT,4);

	m_sbServerPort.SetRange32(1,65535);
	m_sbLockPort.SetRange32(1,65535);

	bufLen=sizeof(buf);
	if(RegQueryValueEx(g_hServerKey,_T("TempDir"),NULL,&dwType,buf,&bufLen) &&
	   SHRegGetUSValue(_T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"),_T("TEMP"),NULL,(LPVOID)buf,&bufLen,TRUE,NULL,0) &&
	   !GetEnvironmentVariable(_T("TEMP"),(LPTSTR)buf,sizeof(buf)) &&
	   !GetEnvironmentVariable(_T("TMP"),(LPTSTR)buf,sizeof(buf)))
		{
			// Not set
			*buf='\0';
		}

	m_edTempDir.SetWindowText((LPCTSTR)buf);

	m_cbEncryption.ResetContent();
	m_cbEncryption.SetItemData(m_cbEncryption.AddString(_T("Optional")),0);
	m_cbEncryption.SetItemData(m_cbEncryption.AddString(_T("Request Authentication")),1);
	m_cbEncryption.SetItemData(m_cbEncryption.AddString(_T("Request Encryption")),2);
	m_cbEncryption.SetItemData(m_cbEncryption.AddString(_T("Require Authentication")),3);
	m_cbEncryption.SetItemData(m_cbEncryption.AddString(_T("Require Encryption")),4);
	m_cbCompression.ResetContent();
	m_cbCompression.SetItemData(m_cbCompression.AddString(_T("Optional")),0);
	m_cbCompression.SetItemData(m_cbCompression.AddString(_T("Request Compression")),1);
	m_cbCompression.SetItemData(m_cbCompression.AddString(_T("Require Compression")),2);

	m_cbEncryption.SetCurSel((t=QueryDword(_T("EncryptionLevel")))>=0?t:0);
	m_cbCompression.SetCurSel((t=QueryDword(_T("CompressionLevel")))>=0?t:0);

	/* Migrate the old setting */
	if((t=QueryDword(_T("DontUseDomain")))>=0)
	{
		if(t)
		{
			/* If dont use domain is set, force domain to computer name */
			/* The server will automatically pick up the domain otherwise */
			bufLen=sizeof(buf);
			GetComputerName((LPTSTR)buf,&bufLen);
			RegSetValueEx(g_hServerKey,_T("DefaultDomain"),0,REG_SZ,(BYTE*)buf,_tcslen((LPCTSTR)buf));
		}
		RegDeleteValue(g_hServerKey,_T("DontUseDomain"));
		if(g_bPrivileged)
			GetParent()->PostMessage(PSM_CHANGED, (WPARAM)m_hWnd); /* SetModified happens too early */
	}

	m_cbDefaultDomain.ResetContent();
	DWORD dwLen = sizeof(mw_computer)/sizeof(mw_computer[0]);

	m_cbDefaultDomain.AddString(_T("(default)"));

	GetComputerName(mw_computer,&dwLen);
	m_cbDefaultDomain.AddString(mw_computer);
	if(isDomainMember(mw_domain))
	{
		LPWSTR pw_pdc;
		m_cbDefaultDomain.AddString(mw_domain);
		if(!NetGetAnyDCName(NULL,mw_domain,(LPBYTE*)&pw_pdc) || !NetGetDCName(NULL,mw_domain,(LPBYTE*)&pw_pdc))
		{
			wcscpy(mw_pdc,pw_pdc);
			NetApiBufferFree(pw_pdc);
		}
	}

	CString szDefaultDomain = QueryString(_T("DefaultDomain"));
	int n = m_cbDefaultDomain.FindStringExact(-1,szDefaultDomain);
	m_cbDefaultDomain.SetCurSel(n>0?n:0);

	m_cbRunAsUser.ResetContent();
	m_cbRunAsUser.AddString(_T("(client user)"));
	CString usr = QueryString(_T("RunAsUser"));
	if(!usr.GetLength())
		m_cbRunAsUser.SetCurSel(0);
	else
		m_cbRunAsUser.SetCurSel(m_cbRunAsUser.AddString(usr));

	if(!g_bPrivileged)
	{
		m_edTempDir.EnableWindow(FALSE);
		m_edLockServer.EnableWindow(FALSE);
		m_cbEncryption.EnableWindow(FALSE);
		m_cbCompression.EnableWindow(FALSE);
		m_sbServerPort.EnableWindow(FALSE);
		m_sbLockPort.EnableWindow(FALSE);
		m_cbDefaultDomain.EnableWindow(FALSE);
		m_cbRunAsUser.EnableWindow(FALSE);
		m_edAnonUser.EnableWindow(FALSE);
		::EnableWindow(*GetDlgItem(IDC_CHANGETEMP),FALSE);
		::EnableWindow(*GetDlgItem(IDC_LOCKSERVERPORT),FALSE);
		::EnableWindow(*GetDlgItem(IDC_PSERVERPORT),FALSE);
	}

	return TRUE;
}