当前位置: 首页>>代码示例>>C++>>正文


C++ SetThreadDesktop函数代码示例

本文整理汇总了C++中SetThreadDesktop函数的典型用法代码示例。如果您正苦于以下问题:C++ SetThreadDesktop函数的具体用法?C++ SetThreadDesktop怎么用?C++ SetThreadDesktop使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetThreadDesktop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Thread_Desktop

/************************************************
 * Create a new Desktop and run a Thread in it. *
 * (Win NT+).                                   *
 ************************************************/
int DLL_EXP_IMP WINAPI Thread_Desktop(LPTHREAD_START_ROUTINE ThreadFunc, THREAD_DATA *td)
{
	HDESK	hOriginalThread;
	HDESK	hOriginalInput;
	HDESK	hNewDesktop;

	// Save original ...
	hOriginalThread = GetThreadDesktop(GetCurrentThreadId());
	hOriginalInput = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);

	// Create a new Desktop and switch to it
	hNewDesktop = CreateDesktop(td->szDesktopName, NULL, NULL, 0, GENERIC_ALL, NULL);
	SetThreadDesktop(hNewDesktop);
	SwitchDesktop(hNewDesktop);

	// Execute thread in new desktop
	td->hDesk = hNewDesktop;
	StartThread(ThreadFunc, td);

	// Restore original ...
	SwitchDesktop(hOriginalInput);
	SetThreadDesktop(hOriginalThread);

	// Close the Desktop
	CloseDesktop(hNewDesktop);

	return 0;
}
开发者ID:justdan96,项目名称:VNCappWrapper,代码行数:32,代码来源:WinLockDLL.c

示例2: SetUserDesktop

int SetUserDesktop( int mode )
{
    static HWINSTA hwinstaSave; 
    static HDESK hdeskSave; 
    static HWINSTA hwinstaUser; 
    static HDESK hdeskUser; 
	
	if(mode == 1) {
		hwinstaSave = GetProcessWindowStation(); 
		hdeskSave = GetThreadDesktop(GetCurrentThreadId()); 
		
		hwinstaUser = OpenWindowStation("WinSta0", FALSE, MAXIMUM_ALLOWED); 
		if (hwinstaUser == NULL) 
			return 0; 
		SetProcessWindowStation(hwinstaUser); 
		hdeskUser = OpenDesktop("Default", 0, FALSE, MAXIMUM_ALLOWED); 
		if (hdeskUser == NULL) { 
			SetProcessWindowStation(hwinstaSave); 
			CloseWindowStation(hwinstaUser); 
			return 0; 
		} 
		SetThreadDesktop(hdeskUser); 
	} 
	else if(mode == 0) {
		SetThreadDesktop(hdeskSave); 
		SetProcessWindowStation(hwinstaSave); 
		CloseDesktop(hdeskUser); 
		CloseWindowStation(hwinstaUser); 
	}
	
    return 0; 
} 
开发者ID:kilitary,项目名称:ss,代码行数:32,代码来源:desktop.cpp

示例3: Process_Desktop

/*************************************************
 * Create a new Desktop and run a Process in it. *
 * (Win NT+).                                    *
 *************************************************/
int DLL_EXP_IMP WINAPI Process_Desktop(char *szDesktopName, char *szPath)
{
	HDESK	hOriginalThread;
	HDESK	hOriginalInput;
	HDESK	hNewDesktop;

	// Save original ...
	hOriginalThread = GetThreadDesktop(GetCurrentThreadId());
	hOriginalInput = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);

	// Create a new Desktop and switch to it
	hNewDesktop = CreateDesktop(szDesktopName, NULL, NULL, 0, GENERIC_ALL, NULL);
	SetThreadDesktop(hNewDesktop);
	SwitchDesktop(hNewDesktop);

	// Execute process in new desktop
	StartProcess(szDesktopName, szPath);

	// Restore original ...
	SwitchDesktop(hOriginalInput);
	SetThreadDesktop(hOriginalThread);

	// Close the Desktop
	CloseDesktop(hNewDesktop);

	return 0;
}
开发者ID:justdan96,项目名称:VNCappWrapper,代码行数:31,代码来源:WinLockDLL.c

示例4: pem_passwd_cb

int pem_passwd_cb(char *buf, int size, int rwflag, void *userdata) {
    int result;
#if 0
    DWORD dwThreadId;
    HWINSTA hwinstaSave;
    HDESK hdeskSave;
    HWINSTA hwinstaUser;
    HDESK hdeskUser;

    buf[0]='\0'; /* empty the buffer */

    /* Save the window station and desktop */
    hwinstaSave=GetProcessWindowStation();
    if(!hwinstaSave)
        ioerror("GetProcessWindowStation");
    dwThreadId=GetCurrentThreadId();
    if(!dwThreadId)
        ioerror("GetCurrentThreadId");
    hdeskSave=GetThreadDesktop(dwThreadId);
    if(!hdeskSave)
        ioerror("GetThreadDesktop");

    /* Switch to WinSta0/Default */
    hwinstaUser=OpenWindowStation("winsta0", FALSE, MAXIMUM_ALLOWED);
    if(!hwinstaUser)
        ioerror("OpenWindowStation");
    if(!SetProcessWindowStation(hwinstaUser))
        ioerror("SetProcessWindowStation");
    hdeskUser=OpenDesktop("Default", 0, FALSE, MAXIMUM_ALLOWED); /* Winlogon */
    if(!hdeskUser)
        ioerror("OpenDesktop");
    if(!SetThreadDesktop(hdeskUser))
        ioerror("SetThreadDesktop");
#endif

    /* Display the dialog box */
    section=userdata;
    result=DialogBox(ghInst, TEXT("PassBox"), hwnd, (DLGPROC)pass_proc);

#if 0
    /* Restore window station and desktop */
    if(!SetThreadDesktop(hdeskSave))
        ioerror("SetThreadDesktop");
    if(!SetProcessWindowStation(hwinstaSave))
        ioerror("SetProcessWindowStation");
    if(!CloseDesktop(hdeskUser))
        ioerror("CloseDesktop");
    if(!CloseWindowStation(hwinstaUser))
        ioerror("CloseWindowStation");
#endif

    if(!result)
        return 0;
    strncpy(buf, passphrase, size);
    buf[size - 1] = '\0';
    return strlen(buf);
}
开发者ID:djs55,项目名称:stunnel,代码行数:57,代码来源:gui.c

示例5: Test_OpenInputDesktop

void Test_OpenInputDesktop()
{
    HDESK hDeskInput ,hDeskInput2;
    HDESK hDeskInitial;
    BOOL ret;
    HWINSTA hwinsta = NULL, hwinstaInitial;
    DWORD err;

    hDeskInput = OpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS);
    ok(hDeskInput != NULL, "OpenInputDesktop failed\n");
    hDeskInitial = GetThreadDesktop( GetCurrentThreadId() );
    ok(hDeskInitial != NULL, "GetThreadDesktop failed\n");
    ok(hDeskInput != hDeskInitial, "OpenInputDesktop returned thread desktop\n");

    hDeskInput2 = OpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS);
    ok(hDeskInput2 != NULL, "Second call to OpenInputDesktop failed\n");
    ok(hDeskInput2 != hDeskInput, "Second call to OpenInputDesktop returned same handle\n");

    ok(CloseDesktop(hDeskInput2) != 0, "CloseDesktop failed\n");

    ret = SetThreadDesktop(hDeskInput);
    ok(ret == TRUE, "SetThreadDesktop for input desktop failed\n");

    ret = SetThreadDesktop(hDeskInitial);
    ok(ret == TRUE, "SetThreadDesktop for initial desktop failed\n");

    ok(CloseDesktop(hDeskInput) != 0, "CloseDesktop failed\n");

    /* Try calling OpenInputDesktop after switching to a new winsta */
    hwinstaInitial = GetProcessWindowStation();
    ok(hwinstaInitial != 0, "GetProcessWindowStation failed\n");

    hwinsta = CreateWindowStationW(L"TestWinsta", 0, WINSTA_ALL_ACCESS, NULL);
    ok(hwinsta != 0, "CreateWindowStationW failed\n");

    ret = SetProcessWindowStation(hwinsta);
    ok(ret != 0, "SetProcessWindowStation failed\n");

    hDeskInput = OpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS);
    ok(hDeskInput == 0, "OpenInputDesktop should fail\n");

    err = GetLastError();
    ok(err == ERROR_INVALID_FUNCTION, "Got last error: %lu\n", err);

    ret = SetProcessWindowStation(hwinstaInitial);
    ok(ret != 0, "SetProcessWindowStation failed\n");

    ret = CloseWindowStation(hwinsta);
    ok(ret != 0, "CloseWindowStation failed\n");

}
开发者ID:hoangduit,项目名称:reactos,代码行数:51,代码来源:desktop.c

示例6: _tWinMain

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	try {
  wchar_t* desktop   = L"NewDesktop";

  HDESK hThreadDT = GetThreadDesktop(GetCurrentThreadId());
  HDESK hInputDT  = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
  HDESK hNewDT    = CreateDesktop(desktop, NULL, NULL, 0, GENERIC_ALL, NULL);

  SetThreadDesktop(hNewDT);
  SwitchDesktop(hNewDT);

   PROCESS_INFORMATION pi;
    STARTUPINFO si;

    memset(&pi, 0, sizeof(pi));
    memset(&si, 0, sizeof(si));
    si.cb = sizeof(si);
    si.lpDesktop = desktop;

	wchar_t cmdline[MAX_PATH];
	wsprintf(cmdline, L"%s %s", L"NAMCredentialWizard.exe", L"/u");
	if (CreateProcess(L"NAMCredentialWizard.exe", cmdline,
		NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {

      WaitForSingleObject(pi.hProcess, INFINITE);
    }
    else {
      wchar_t msg[1000];
      wsprintf(msg,L"CreateProcess failed (%d)",GetLastError());
      MessageBox(NULL,msg,NULL,MB_OK);
    }
  

  SwitchDesktop(hInputDT);
  SetThreadDesktop(hThreadDT);
  CloseDesktop(hNewDT);

  return 0;

	} catch(...)
	{ MessageBox(NULL,L"Caught Exception",NULL,MB_OK);


	}
}
开发者ID:ludup,项目名称:modalme,代码行数:49,代码来源:ModalMe.cpp

示例7: BlackWindow

DWORD WINAPI BlackWindow(LPVOID lpParam)
{
 	// TODO: Place code here.
	HDESK desktop;
	desktop = OpenInputDesktop(0, FALSE,
								DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
								DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
								DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
								DESKTOP_SWITCHDESKTOP | GENERIC_WRITE
								);

	if (desktop == NULL)
		vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop Error \n"));
	else 
		vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop OK\n"));

	HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
	DWORD dummy;

	char new_name[256];
	if (desktop)
	{
		if (!GetUserObjectInformation(desktop, UOI_NAME, &new_name, 256, &dummy))
		{
			vnclog.Print(LL_INTERR, VNCLOG("!GetUserObjectInformation \n"));
		}

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

		if (!SetThreadDesktop(desktop))
		{
			vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK:!SetThreadDesktop \n"));
		}
	}

	create_window();
	MSG msg;
	while (GetMessage(&msg,0,0,0) != 0)
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	vnclog.Print(LL_INTERR, VNCLOG("end BlackWindow \n"));
	SetThreadDesktop(old_desktop);
	if (desktop) CloseDesktop(desktop);

	return 0;
}
开发者ID:copilot-com,项目名称:CopilotVNC,代码行数:48,代码来源:black_layered.cpp

示例8: KillWindow

void KillWindow() {
    window_ready=false;
    wglMakeCurrent(NULL,NULL);  // release GL rendering context
    if (hRC) {
        wglDeleteContext(hRC);
        hRC=NULL;
    }

    if (hWnd && hDC) {
        ReleaseDC(hWnd,hDC);
    }
    hDC = NULL;

    if (hWnd) {
        DestroyWindow(hWnd);
    }
    hWnd = NULL;

    if (hOriginalWindowStation) {
        SetProcessWindowStation(hOriginalWindowStation);
        CloseWindowStation(hInteractiveWindowStation);
        hInteractiveWindowStation = NULL;
    }

    if (hOriginalDesktop) {
        SetThreadDesktop(hOriginalDesktop);
        CloseDesktop(hInteractiveDesktop);
        hInteractiveDesktop = NULL;
    }
}
开发者ID:drshawnkwang,项目名称:boinc,代码行数:30,代码来源:windows_opengl.cpp

示例9: GetThreadDesktop

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;
}
开发者ID:bk138,项目名称:CollabTool,代码行数:34,代码来源:vncService.cpp

示例10:

    ~EnterDesktop()
	{
        if (old)
		{
            if (!SetThreadDesktop(old)) LCF1(L"SetThreadDesktop failed: %d", GetLastError());
        }
    }
开发者ID:vladimirlozhnikov,项目名称:ginafull,代码行数:7,代码来源:StatusWindow.cpp

示例11: SelectDesktop

bool SelectDesktop()
{
		HDESK desktop;
		HDESK old_desktop;
		DWORD dummy;
		char new_name[256];
		desktop = OpenInputDesktop(0, FALSE,
				DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
				DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
				DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
				DESKTOP_SWITCHDESKTOP | GENERIC_WRITE);
		if (desktop == NULL) return FALSE;
		old_desktop = GetThreadDesktop(GetCurrentThreadId());
		if (!GetUserObjectInformation(desktop, UOI_NAME, &new_name, 256, &dummy)) {
			CloseDesktop(desktop);
			return FALSE;
		}
		if(!SetThreadDesktop(desktop)) {
			CloseDesktop(desktop);
			return FALSE;
		}
		CloseDesktop(old_desktop);			
		return TRUE;

}
开发者ID:runsoftcorp,项目名称:runremote,代码行数:25,代码来源:uvnckeyboardhelper.cpp

示例12: GetThreadDesktop

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;
}
开发者ID:FrantisekKlika,项目名称:UltraVncAsDll,代码行数:29,代码来源:vncservice.cpp

示例13: SwitchInputDesktop

bool SwitchInputDesktop()
{
    BOOL	bRet = false;
    DWORD	dwLengthNeeded;

    HDESK	hOldDesktop, hNewDesktop;
    char	strCurrentDesktop[256], strInputDesktop[256];

    hOldDesktop = GetThreadDesktop(GetCurrentThreadId());
    memset(strCurrentDesktop, 0, sizeof(strCurrentDesktop));
    GetUserObjectInformation(hOldDesktop, UOI_NAME, &strCurrentDesktop, sizeof(strCurrentDesktop), &dwLengthNeeded);


    hNewDesktop = OpenInputDesktop(0, FALSE, MAXIMUM_ALLOWED);
    memset(strInputDesktop, 0, sizeof(strInputDesktop));
    GetUserObjectInformation(hNewDesktop, UOI_NAME, &strInputDesktop, sizeof(strInputDesktop), &dwLengthNeeded);

    if (lstrcmpi(strInputDesktop, strCurrentDesktop) != 0)
    {
        SetThreadDesktop(hNewDesktop);
        bRet = true;
    }
    CloseDesktop(hOldDesktop);

    CloseDesktop(hNewDesktop);


    return bRet;
}
开发者ID:xinba123,项目名称:shell,代码行数:29,代码来源:until.cpp

示例14: GetThreadDesktop

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;
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:29,代码来源:vncservice.cpp

示例15: GetThreadDesktop

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;
}
开发者ID:isaudits,项目名称:scripts,代码行数:32,代码来源:vncService.cpp


注:本文中的SetThreadDesktop函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。