Ejemplo n.º 1
1
BOOL
vncService::SelectHDESK(HDESK new_desktop)
{
	// Are we running on NT?
	if (IsWinNT())
	{
		HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());

		DWORD dummy;
		char new_name[256];

		if (!GetUserObjectInformation(new_desktop, UOI_NAME, &new_name, 256, &dummy)) {

			return FALSE;
		}



		// Switch the desktop
		if(!SetThreadDesktop(new_desktop)) {

			return FALSE;
		}

		// Switched successfully - destroy the old desktop
		CloseDesktop(old_desktop);

		return TRUE;
	}

	return TRUE;
}
Ejemplo n.º 2
1
BOOL
vncService::SelectHDESK(HDESK new_desktop)
{
	// Are we running on NT?
	if (IsWinNT())
	{
		HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());

		DWORD dummy;
		char new_name[256];

		if (!GetUserObjectInformation(new_desktop, UOI_NAME, &new_name, 256, &dummy)) {
			vnclog.Print(LL_INTERR, VNCLOG("!GetUserObjectInformation \n"));
			return FALSE;
		}

		vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK to %s (%x) from %x\n"), new_name, new_desktop, old_desktop);

		// Switch the desktop
		if(!SetThreadDesktop(new_desktop)) {
			vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK:!SetThreadDesktop \n"));
			return FALSE;
		}

		return TRUE;
	}

	return TRUE;
}
Ejemplo n.º 3
0
BOOL
vncService::SimulateCtrlAltDel()
{
	vnclog.Print(LL_ALL, VNCLOG("preparing to generate ctrl-alt-del\n"));

	// Are we running on NT?
	if (IsWinNT())
	{
		vnclog.Print(LL_ALL, VNCLOG("spawn ctrl-alt-del thread...\n"));

		// We simulate Ctrl+Alt+Del by posting a WM_HOTKEY message to the
		// "SAS window" on the Winlogon desktop.
		// This requires that the current thread is part of the Winlogon desktop.
		// But the current thread has hooks set & a window open, so it can't
		// switch desktops, so I instead spawn a new thread & let that do the work...

		omni_thread *thread = omni_thread::create(SimulateCtrlAltDelThreadFn);
		if (thread == NULL)
			return FALSE;
		thread->join(NULL);

		return TRUE;
	}

	return TRUE;
}
Ejemplo n.º 4
0
BOOL
vncService::SelectHDESK(HDESK new_desktop)
{
	// Are we running on NT?
	if (IsWinNT())
	{
		HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());

		DWORD dummy;
		char new_name[256];

		if (!GetUserObjectInformation(new_desktop, UOI_NAME, &new_name, 256, &dummy)) {
			vnclog.Print(LL_INTERR, VNCLOG("GetUserObjectInformation() failed\n"));
			return FALSE;
		}

		vnclog.Print(LL_INTINFO, VNCLOG("SelectHDESK() to %s (%x) from %x\n"),
					 new_name, new_desktop, old_desktop);

		// Switch the desktop
		if(!SetThreadDesktop(new_desktop)) {
			vnclog.Print(LL_INTERR, VNCLOG("unable to SetThreadDesktop(), error=%d\n"), GetLastError());
			return FALSE;
		}

		// Switched successfully - destroy the old desktop
		if (!CloseDesktop(old_desktop))
			vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK failed to close old desktop %x, error=%d\n"), old_desktop, GetLastError());

		return TRUE;
	}

	return TRUE;
}
Ejemplo n.º 5
0
/*
 * WriteSystemEnv() -- write system environment variable
 */
BOOL WriteSystemEnv(char *pszEnvValue, char *pszEnvName)
{
    if (IsWinNT())
	return WriteRegEnv(pszEnvValue, pszEnvName);
    else
	return WriteAutoExec(pszEnvValue, pszEnvName);
}
Ejemplo n.º 6
0
bool FileCopy(const char *oldname, const char *newname)
{
#if defined(PLATFORM_WIN32)
	if(IsWinNT())
		return UnicodeWin32().CopyFileW(ToSystemCharsetW(oldname), ToSystemCharsetW(newname), false);
	else
		return CopyFile(ToSystemCharset(oldname), ToSystemCharset(newname), false);
#elif defined(PLATFORM_POSIX)
	FileIn fi(oldname);
	if(!fi.IsOpen())
		return false;
	FileOut fo(newname);
	if(!fo.IsOpen())
		return false;
	CopyStream(fo, fi, fi.GetLeft());
	fi.Close();
	fo.Close();
	if(fo.IsError())
	{
		unlink(newname);
		return false;
	}
	FileSetTime(newname, FileGetTime(oldname));
	return true;
#else
	#error
#endif//PLATFORM
}
Ejemplo n.º 7
0
bool DirectoryCreate(const char *path)
{
	if(IsWinNT())
		return !!UnicodeWin32().CreateDirectoryW(ToSystemCharsetW(path), 0);
	else
		return !!CreateDirectory(ToSystemCharset(path), 0);
}
Ejemplo n.º 8
0
BOOL
vncService::SelectHDESK(HDESK new_desktop)
{
	// Are we running on NT?
	if (IsWinNT())
	{
		HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
		//You do not need to call the CloseDesktop function to close the returned handle.

		DWORD dummy;
		char new_name[256];

		if (!GetUserObjectInformation(new_desktop, UOI_NAME, &new_name, 256, &dummy)) {
			return FALSE;
		}

		//vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK to %s (%x) from %x\n"), new_name, new_desktop, old_desktop);
		
		// Switch the desktop
		if(!SetThreadDesktop(new_desktop)) 
		{
			return FALSE;
		}

		return TRUE;
	}

	return TRUE;
}
Ejemplo n.º 9
0
bool SetFileTime(const char *filename, FileTime ft)
{
#if defined(PLATFORM_WIN32)
	HANDLE handle;
	if(IsWinNT())
		handle = UnicodeWin32().CreateFileW(ToSystemCharsetW(filename), GENERIC_READ | GENERIC_WRITE,
			FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
			OPEN_EXISTING, 0, NULL);
	else
		handle = CreateFile(ToSystemCharset(filename), GENERIC_READ | GENERIC_WRITE,
			FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
			OPEN_EXISTING, 0, NULL);
	if(handle == INVALID_HANDLE_VALUE)
		return false;
	bool res = SetFileTime(handle, 0, 0, &ft);
	CloseHandle(handle);
	return res;
#elif defined(PLATFORM_POSIX)
	struct utimbuf ub;
	ub.actime = ub.modtime = ft;
	return !utime(ToSystemCharset(filename), &ub);
#else
	#error
#endif//PLATFORM
}
Ejemplo n.º 10
0
BOOL DelayCopy(char *src, char *dst)
{
	char	tmp_file[MAX_PATH];
	BOOL	ret = FALSE;

	wsprintf(tmp_file, "%s.new", dst);

	if (MiniCopy(src, tmp_file) == FALSE)
		return	FALSE;

	if (IsWinNT()) {
		ret = ::MoveFileEx(tmp_file, dst, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
	}
	else {
		char	win_ini[MAX_PATH], short_tmp[MAX_PATH], short_dst[MAX_PATH];

		::GetShortPathName(tmp_file, short_tmp, sizeof(short_tmp));
		::GetShortPathName(dst, short_dst, sizeof(short_dst));
		::GetWindowsDirectory(win_ini, sizeof(win_ini));
		strcat(win_ini, "\\WININIT.INI");
		// WritePrivateProfileString("Rename", "NUL", short_dst, win_ini); 必要なさそ
		ret = WritePrivateProfileString("Rename", short_dst, short_tmp, win_ini);
	}
	return	ret;
}
Ejemplo n.º 11
0
BOOL vncVideoDriver::TestMapped()
{
	_ASSERTE(IsWinNT());

	TCHAR *pDevName;
	if (IsWinVerOrHigher(5, 0))
	{
		DISPLAY_DEVICE dd;
		INT devNum = 0;
		if (!LookupVideoDeviceAlt(szDriverString, szDriverStringAlt, devNum, &dd))
			return FALSE;
		pDevName = (TCHAR *)dd.DeviceName;
	}
	else
	{
		pDevName = "DISPLAY";
	}

	HDC	l_ddc = ::CreateDC(pDevName, NULL, NULL, NULL);
	if (l_ddc)
	{
		BOOL b = ExtEscape(l_ddc, TESTMAPPED, 0, NULL, 0, NULL);	
		DeleteDC(l_ddc);
		return b;
	}
	return FALSE;
}
Ejemplo n.º 12
0
FileTime GetFileTime(const char *filename)
{
#if defined(PLATFORM_WIN32)
	HANDLE handle;
	if(IsWinNT())
		handle = UnicodeWin32().CreateFileW(ToSystemCharsetW(filename), GENERIC_READ,
		                    FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
	else
		handle = CreateFile(ToSystemCharset(filename), GENERIC_READ,
		                    FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
	FileTime ft0;
	memset(&ft0, 0, sizeof(ft0));
	if(handle == INVALID_HANDLE_VALUE)
		return ft0;
	FileTime ft;
	bool res = GetFileTime(handle, 0, 0, &ft);
	CloseHandle(handle);
	return res ? ft : ft0;
#elif defined(PLATFORM_POSIX)
	struct stat st;
	if(stat(ToSystemCharset(filename), &st))
		return 0;
	return st.st_mtime;
#else
	#error
#endif//PLATFORM
}
Ejemplo n.º 13
0
/*
 * ReadSystemEnv() -- read system environment variable
 */
BOOL ReadSystemEnv(char **ppszEnvValue, char *pszEnvName)
{
    if (IsWinNT())
	return ReadRegEnv(ppszEnvValue, pszEnvName);
    else
	return ReadAutoExec(ppszEnvValue, pszEnvName);
}
Ejemplo n.º 14
0
BOOL vncVideoDriver::MapSharedbuffers(BOOL fForDirectScreenAccess)
{
	_ASSERTE(!m_fIsActive);
	_ASSERTE(!m_fDirectAccessInEffect);
	_ASSERTE(IsWinNT());

	HDC	l_gdc= ::CreateDC(m_devname, NULL, NULL, NULL);
	if (!l_gdc)
	{
		vnclog.Print(
			LL_INTERR,
			VNCLOG("vncVideoDriver::MapSharedbuffers: can't create DC on \"%s\"\n"),
			m_devname);
		return FALSE;
	}

	oldCounter = 0;
	int drvCr = ExtEscape(
		l_gdc,
		MAP1,
		0, NULL,
		sizeof(GETCHANGESBUF), (LPSTR) &bufdata);
	DeleteDC(l_gdc);

	if (drvCr <= 0)
	{
		vnclog.Print(
			LL_INTERR,
			VNCLOG("vncVideoDriver::MapSharedbuffers: MAP1 call returned 0x%x\n"),
			drvCr);
		return FALSE;
	}
	m_fIsActive = true;
	if (fForDirectScreenAccess)
	{
		if (!bufdata.Userbuffer)
		{
			vnclog.Print(
				LL_INTERR,
				VNCLOG("vncVideoDriver::MapSharedbuffers: mirror screen view is NULL\n"));
			return FALSE;
		}
		m_fDirectAccessInEffect = true;
	}
	else
	{
		if (bufdata.Userbuffer)
		{
			vnclog.Print(
				LL_INTINFO,
				VNCLOG("vncVideoDriver::MapSharedbuffers: mirror screen view is mapped but direct access mode is OFF\n"));
		}
	}

// Screen2Screen support added in Mirage ver 1.2
	m_fHandleScreen2ScreenBlt = (m_drv_ver_mj > 1) || (m_drv_ver_mj == 1 && m_drv_ver_mn >= 2);

	return TRUE;	
}
Ejemplo n.º 15
0
// - SelectDesktop(char *)
// Switches the current thread into a different desktop, by name
// Calling with a valid desktop name will place the thread in that desktop.
// Calling with a NULL name will place the thread in the current input desktop.
BOOL
vncService::SelectDesktop(char *name, HDESK *new_desktop)
{
	//return false;
	// Are we running on NT?
	if (IsWinNT())
	{
		HDESK desktop;
		vnclog.Print(LL_INTERR, VNCLOG("SelectDesktop \n"));
		if (name != NULL)
		{
			vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop2 named\n"));
			// Attempt to open the named desktop
			desktop = OpenDesktop(name, 0, FALSE,
				DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
				DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
				DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
				DESKTOP_SWITCHDESKTOP | GENERIC_WRITE);
		}
		else
		{
			vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop2 NULL\n"));
			// No, so open the input desktop
			desktop = OpenInputDesktop(0, FALSE,
				DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
				DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
				DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
				DESKTOP_SWITCHDESKTOP | GENERIC_WRITE);
		}

		// Did we succeed?
		if (desktop == NULL) {
				vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop2 \n"));
				return FALSE;
		}
		else vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop2 OK\n"));

		// Switch to the new desktop
		if (!SelectHDESK(desktop)) {
			// Failed to enter the new desktop, so free it!
			if (!CloseDesktop(desktop))
				vnclog.Print(LL_INTERR, VNCLOG("SelectDesktop failed to close desktop\n"));
			return FALSE;
		}


		if (new_desktop)
		{
			if (*new_desktop)
				CloseDesktop(*new_desktop);
			*new_desktop = desktop;
		}

		// We successfully switched desktops!
		return TRUE;
	}

	return (name == NULL);
}
Ejemplo n.º 16
0
void unmap_phys_mem(void *ptr, unsigned long size) {
  if(IsWinNT()){
    dhahelper_t dhahelper_priv;
    DWORD dwBytesReturned;
    dhahelper_priv.ptr = ptr;
    DeviceIoControl(hDriver, IOCTL_DHAHELPER_UNMAPPHYSADDR, &dhahelper_priv,sizeof(dhahelper_t), NULL, 0, &dwBytesReturned, NULL);
  }
}
Ejemplo n.º 17
0
static __inline__ int disable_os_io(void)
{
    if(IsWinNT()){
      DWORD dwBytesReturned;
      DeviceIoControl(hDriver, IOCTL_DHAHELPER_DISABLEDIRECTIO, NULL,0, NULL, 0, &dwBytesReturned, NULL);
      CloseHandle(hDriver);
    }
    return 0;
}
Ejemplo n.º 18
0
void FindFile::Init()
{
	if(IsWinNT()) {
		w = new WIN32_FIND_DATAW;
		a = NULL;
	}
	else {
		a = new WIN32_FIND_DATA;
		w = NULL;
	}
}
Ejemplo n.º 19
0
HWND GetParentHwnd()
{
   if (IsWinNT())
   {
      return GetDesktopWindow();
   }
   else
   {
      return GetForegroundWindow();
   }
}
Ejemplo n.º 20
0
int
my_fstat(int fd, Stat_t *sbufptr)
{
    /* This fixes a bug in fstat() on Windows 9x.  fstat() uses the
     * GetFileType() win32 syscall, which will fail on Windows 9x.
     * So if we recognize a socket on Windows 9x, we return the
     * same results as on Windows NT/2000.
     * XXX this should be extended further to set S_IFSOCK on
     * sbufptr->st_mode.
     */
    int osf;
    if (!wsock_started || IsWinNT()) {
#if defined(WIN64) || defined(USE_LARGE_FILES)
#if defined(__BORLANDC__) /* buk */
	return win32_fstat(fd, sbufptr );
#else
	return _fstati64(fd, sbufptr);
#endif
#else
	return fstat(fd, sbufptr);
#endif
    }

    osf = TO_SOCKET(fd);
    if (osf != -1) {
	char sockbuf[256];
	int optlen = sizeof(sockbuf);
	int retval;

	retval = getsockopt((SOCKET)osf, SOL_SOCKET, SO_TYPE, sockbuf, &optlen);
	if (retval != SOCKET_ERROR || WSAGetLastError() != WSAENOTSOCK) {
#if defined(__BORLANDC__)&&(__BORLANDC__<=0x520)
	    sbufptr->st_mode = S_IFIFO;
#else
	    sbufptr->st_mode = _S_IFIFO;
#endif
	    sbufptr->st_rdev = sbufptr->st_dev = (dev_t)fd;
	    sbufptr->st_nlink = 1;
	    sbufptr->st_uid = sbufptr->st_gid = sbufptr->st_ino = 0;
	    sbufptr->st_atime = sbufptr->st_mtime = sbufptr->st_ctime = 0;
	    sbufptr->st_size = (Off_t)0;
	    return 0;
	}
    }
#if defined(WIN64) || defined(USE_LARGE_FILES)
#if defined(__BORLANDC__) /* buk */
    return win32_fstat(fd, sbufptr );
#else
    return _fstati64(fd, sbufptr);
#endif
#else
    return fstat(fd, sbufptr);
#endif
}
Ejemplo n.º 21
0
static __inline__ int enable_os_io(void)
{
    if(IsWinNT()){
      DWORD dwBytesReturned;
      hDriver = CreateFile("\\\\.\\DHAHELPER",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
      if(!DeviceIoControl(hDriver, IOCTL_DHAHELPER_ENABLEDIRECTIO, NULL,0, NULL, 0, &dwBytesReturned, NULL)){
        fprintf(stderr,"Unable to enable directio please install dhahelper.sys.\n");
        return 1;
      }
    }
    return 0;
}
Ejemplo n.º 22
0
LONG CTCPropBagOnRegKey::QueryString(HKEY hkey, const _bstr_t& strValueName,
  _bstr_t& strOut)
{
  bool bIsWinNT = IsWinNT();
  DWORD cbData;
  LONG lr = bIsWinNT ?
    RegQueryValueExW(hkey, strValueName, NULL, NULL, NULL, &cbData) :
    RegQueryValueExA(hkey, strValueName, NULL, NULL, NULL, &cbData);

  // Allocate a buffer
  LP
}
Ejemplo n.º 23
0
// Fix to avoid black corners temorarily artifact
void Ctrl::Create0(Ctrl::CreateBox *cr)
{
	GuiLock __;
	ASSERT(IsMainThread());
	LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <<UPP::Name(this) << BeginIndent);
	ASSERT(!IsChild() && !IsOpen());
	Rect r = GetRect();
	AdjustWindowRectEx(r, cr->style, FALSE, cr->exstyle);
	isopen = true;
	top = new Top;
	ASSERT(!cr->parent || IsWindow(cr->parent));
	cr->style &= ~WS_VISIBLE;
	if(!IsWinXP())
		cr->dropshadow = false;
#ifdef PLATFORM_WINCE
		if(parent)
			top->hwnd = CreateWindowExW(cr->exstyle,
			                            cr->savebits ? cr->dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W"
			                                         : cr->dropshadow ? L"UPP-CLASS-DS-W"    : L"UPP-CLASS-W",
			                            L"", cr->style, 0, 0, 0, 0,
			                            cr->parent, NULL, hInstance, this);
		else
			top->hwnd = CreateWindowW(L"UPP-CLASS-W",
			                          L"", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
			                          cr->parent, NULL, hInstance, this);
#else
	if(IsWinNT() && (!cr->parent || IsWindowUnicode(cr->parent)))
		top->hwnd = CreateWindowExW(cr->exstyle,
		                            cr->savebits ? cr->dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W"
		                                         : cr->dropshadow ? L"UPP-CLASS-DS-W"    : L"UPP-CLASS-W",
		                            L"", cr->style, 0, 0, 0, 0,
		                            cr->parent, NULL, hInstance, this);
	else
		top->hwnd = CreateWindowEx(cr->exstyle,
		                           cr->savebits ? cr->dropshadow ? "UPP-CLASS-SB-DS-A" : "UPP-CLASS-SB-A"
		                                        : cr->dropshadow ? "UPP-CLASS-DS-A"    : "UPP-CLASS-A",
		                           "", cr->style, 0, 0, 0, 0,
		                           cr->parent, NULL, hInstance, this);
#endif

	inloop = false;

	ASSERT(top->hwnd);

	::MoveWindow(top->hwnd, r.left, r.top, r.Width(), r.Height(), false); // To avoid "black corners" artifact effect
	::ShowWindow(top->hwnd, visible ? cr->show : SW_HIDE);
//	::UpdateWindow(hwnd);
	StateH(OPEN);
	LLOG(EndIndent << "//Ctrl::Create in " <<UPP::Name(this));
	RegisterDragDrop(top->hwnd, (LPDROPTARGET) (top->dndtgt = NewUDropTarget(this)));
	CancelMode();
	RefreshLayoutDeep();
}
Ejemplo n.º 24
0
void Ctrl::Create(HWND parent, DWORD style, DWORD exstyle, bool savebits, int show, bool dropshadow)
{
	GuiLock __;
	ASSERT_(IsMainThread(), "Window creation can only happen in the main thread");
	LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <<UPP::Name(this) << LOG_BEGIN);
	ASSERT(!IsChild() && !IsOpen());
	Rect r = GetRect();
	AdjustWindowRectEx(r, style, FALSE, exstyle);
	isopen = true;
	top = new Top;
	ASSERT(!parent || IsWindow(parent));
	style &= ~WS_VISIBLE;
	if(!IsWinXP())
		dropshadow = false;
#ifdef PLATFORM_WINCE
		if(parent)
			top->hwnd = CreateWindowExW(exstyle,
			                            savebits ? dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W"
			                                         : dropshadow ? L"UPP-CLASS-DS-W"    : L"UPP-CLASS-W",
			                            L"", style, 0, 0, 0, 0,
			                            parent, NULL, hInstance, this);
		else
			top->hwnd = CreateWindowW(L"UPP-CLASS-W",
			                          L"", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
			                          parent, NULL, hInstance, this);
#else
	if(IsWinNT() && (!parent || IsWindowUnicode(parent)))
		top->hwnd = CreateWindowExW(exstyle,
		                            savebits ? dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W"
		                                         : dropshadow ? L"UPP-CLASS-DS-W"    : L"UPP-CLASS-W",
		                            L"", style, 0, 0, 0, 0,
		                            parent, NULL, hInstance, this);
	else
		top->hwnd = CreateWindowEx(exstyle,
		                           savebits ? dropshadow ? "UPP-CLASS-SB-DS-A" : "UPP-CLASS-SB-A"
		                                        : dropshadow ? "UPP-CLASS-DS-A"    : "UPP-CLASS-A",
		                           "", style, 0, 0, 0, 0,
		                           parent, NULL, hInstance, this);
#endif

	inloop = false;

	ASSERT(top->hwnd);
	::MoveWindow(top->hwnd, r.left, r.top, r.Width(), r.Height(), false); // To avoid "black corners" artifact effect
	::ShowWindow(top->hwnd, visible ? show : SW_HIDE);
//	::UpdateWindow(hwnd);
	StateH(OPEN);
	LLOG(LOG_END << "//Ctrl::Create in " <<UPP::Name(this));
	RegisterDragDrop(top->hwnd, (LPDROPTARGET) (top->dndtgt = NewUDropTarget(this)));
	CancelMode();
	RefreshLayoutDeep();
}
Ejemplo n.º 25
0
bool DeleteRegistryKey(HKEY hKeyRoot, LPCTSTR pszSubKey)
{
    DWORD dwRet = ERROR_SUCCESS;

    if(IsWinNT())
    {
        // WinNT/2K will not allow you to delete keys which have
        // subkeys/values inside them. MS's platform SDK tells you
        // to use the SHDeleteKey function in shlwapi.dll. This dll
        // is not available on NT platforms without IE 4.0 or later.
        // Because of this I first attempt to delete the key in the
        // hope that it is empty. If that is not possible I load shlwapi
        // and call the function in that. This prevents the app bombing
        // out if the dll can't be found.
        if(RegDeleteKey(hKeyRoot, pszSubKey) != ERROR_SUCCESS)
        {
            HINSTANCE hLibInst = LoadLibrary(_T("shlwapi.dll"));

            if(!hLibInst)
            {
                //throw ERROR_NO_SHLWAPI_DLL;
            }

            #if defined(UNICODE) || defined(_UNICODE)
            SHDELKEYPROC DeleteKeyRecursive = (SHDELKEYPROC)GetProcAddress(hLibInst, "SHDeleteKeyW");
            #else
            SHDELKEYPROC DeleteKeyRecursive = (SHDELKEYPROC)GetProcAddress(hLibInst, "SHDeleteKeyA");
            #endif

            if(!DeleteKeyRecursive)
            {
                FreeLibrary(hLibInst);
                //throw ERROR_NO_SHDELETEKEY;
            }

            dwRet = DeleteKeyRecursive(hKeyRoot, pszSubKey);

            FreeLibrary(hLibInst);
        }
    }
    else {
        // Windows 9x will allow RegDeleteKey to delete keys
        // even if they have subkeys/values.
        dwRet = RegDeleteKey(hKeyRoot, pszSubKey);
    }

    if(dwRet == ERROR_SUCCESS)
        return true;

    SetLastError(dwRet);
    return false;
}
Ejemplo n.º 26
0
String GetLocaleInfoA(LCID lcid, LCTYPE lctype)
{
	if(IsWinNT()) {
		wchar cbuf[1000];
		UnicodeWin32().GetLocaleInfoW(lcid, lctype, cbuf, __countof(cbuf));
		return FromSystemCharsetW(cbuf);
	}
	else {
		char cbuf[1000];
		::GetLocaleInfoA(lcid, lctype, cbuf, __countof(cbuf));
		return FromSystemCharset(cbuf);
	}
}
Ejemplo n.º 27
0
bool FileMove(const char *oldname, const char *newname)
{
#if defined(PLATFORM_WIN32)
	if(IsWinNT())
		return !!UnicodeWin32().MoveFileW(ToSystemCharsetW(oldname), ToSystemCharsetW(newname));
	else
		return !!MoveFile(ToSystemCharset(oldname), ToSystemCharset(newname));
#elif defined(PLATFORM_POSIX)
	return !rename(ToSystemCharset(oldname), ToSystemCharset(newname));
#else
	#error
#endif//PLATFORM
}
Ejemplo n.º 28
0
void vncVideoDriver::Deactivate()
{
	_ASSERTE(IsWinNT());

	if (IsWinVerOrHigher(5, 0))
	{
		Deactivate_NT50();
	}
	else
	{
		Deactivate_NT46();
	}
}
Ejemplo n.º 29
0
bool FileDelete(const char *filename)
{
#if defined(PLATFORM_WIN32)
	if(IsWinNT())
		return !!UnicodeWin32().DeleteFileW(ToSystemCharsetW(filename));
	else
		return !!DeleteFile(ToSystemCharset(filename));
#elif defined(PLATFORM_POSIX)
	return !unlink(ToSystemCharset(filename));
#else
	#error
#endif//PLATFORM
}
Ejemplo n.º 30
0
bool DirectoryDelete(const char *dirname)
{
#if defined(PLATFORM_WIN32)
	if(IsWinNT())
		return !!UnicodeWin32().RemoveDirectoryW(ToSystemCharsetW(dirname));
	else
		return !!RemoveDirectory(ToSystemCharset(dirname));
#elif defined(PLATFORM_POSIX)
	return !rmdir(ToSystemCharset(dirname));
#else
	#error
#endif//PLATFORM
}