本文整理汇总了C++中CloseDesktop函数的典型用法代码示例。如果您正苦于以下问题:C++ CloseDesktop函数的具体用法?C++ CloseDesktop怎么用?C++ CloseDesktop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CloseDesktop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: InputDesktopSelected
bool InputDesktopSelected()
{
DWORD dummy;
char threadname[256];
char inputname[256];
HDESK threaddesktop = GetThreadDesktop(GetCurrentThreadId());
HDESK inputdesktop = OpenInputDesktop(0, FALSE,
DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP | GENERIC_WRITE);
if (inputdesktop == NULL) return FALSE;
if (!GetUserObjectInformation(threaddesktop, UOI_NAME, &threadname, 256, &dummy)) {
CloseDesktop(inputdesktop);
return FALSE;
}
if (!GetUserObjectInformation(inputdesktop, UOI_NAME, &inputname, 256, &dummy)) {
CloseDesktop(inputdesktop);
return FALSE;
}
CloseDesktop(inputdesktop);
if (strcmp(threadname, inputname) != 0)
{
//if (strcmp(inputname, "Screen-saver") == 0)
{
return SelectDesktop();
}
return FALSE;
}
return TRUE;
}
开发者ID:runsoftcorp,项目名称:runremote,代码行数:34,代码来源:uvnckeyboardhelper.cpp
示例2: 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
示例3: 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
示例4: VNCLOG
// - 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);
}
开发者ID:FrantisekKlika,项目名称:UltraVncAsDll,代码行数:63,代码来源:vncservice.cpp
示例5: check_winsta
static BOOL CALLBACK
check_winsta(wchar_t* winsta_name, LPARAM)
{
debug(L"entering enum_winsta_proc, winsta_name = %s\n", winsta_name);
// open the window station and connect to it
// (TODO: figure out what permissions are really needed here)
//
HWINSTA winsta = OpenWindowStation(winsta_name, FALSE, MAXIMUM_ALLOWED);
if (winsta == NULL) {
debug(L"OpenWindowStation error: %u\n", GetLastError());
return TRUE;
}
HWINSTA old_winsta = GetProcessWindowStation();
if (SetProcessWindowStation(winsta) == FALSE) {
debug(L"SetProcessWindowStation error: %u\n", GetLastError());
if (CloseWindowStation(winsta) == FALSE) {
debug(L"CloseWindowStation error: %u\n", GetLastError());
}
return TRUE;
}
if (CloseWindowStation(old_winsta) == FALSE) {
debug(L"CloseWindowStation error: %u\n", GetLastError());
}
// open the "default" desktop and connect to it (if present)
// (TODO: figure out what permissions are really needed here)
//
HDESK desktop = OpenDesktop(L"default", 0, FALSE, MAXIMUM_ALLOWED);
if (desktop == NULL) {
debug(L"OpenDesktop error: %u\n", GetLastError());
return TRUE;
}
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
if (SetThreadDesktop(desktop) == FALSE) {
debug(L"SetThreadDesktop error: %u\n", GetLastError());
if (CloseDesktop(desktop) == FALSE) {
debug(L"CloseDesktop error: %u\n", GetLastError());
}
return TRUE;
}
if (CloseDesktop(old_desktop) == FALSE) {
debug(L"CloseDesktop error: %u\n", GetLastError());
}
// check_this_winsta() returns TRUE if it found the pid, FALSE if not
//
BOOL found = check_this_winsta();
if (found) {
SetLastError(ERROR_SUCCESS);
}
// return TRUE to keep searching
return ! found;
}
开发者ID:blueskyll,项目名称:condor,代码行数:54,代码来源:condor_softkill.WINDOWS.cpp
示例6: 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
示例7: SwitchInputDesktop
// get the current input desktop name and compare with
// the desktop the call thread attached ,if not equal,
// then switch to the input desktop
BOOL SwitchInputDesktop()
{
HDESK threaddesk = GetThreadDesktop(GetCurrentThreadId());
HDESK inputdesk = OpenInputDesktop(0, DF_ALLOWOTHERACCOUNTHOOK,GENERIC_ALL);
if (inputdesk == NULL)
{
DebugOutF(filelog::log_error,("OpenInputDesktop failed with %d"),GetLastError());
return FALSE;
}
DWORD len=0;
TCHAR szThread[MAX_PATH];
TCHAR szInput[MAX_PATH];
szThread[0] = _T('\0');
szInput[0] = _T('\0');
BOOL res = FALSE;
try
{
// get desktop name
if(!GetUserObjectInformation(threaddesk, UOI_NAME, szThread, MAX_PATH, &len)){
DebugOutF(filelog::log_error,("GetUserObjectInformation failed with %d"),GetLastError());
throw FALSE;
}
if (!GetUserObjectInformation(inputdesk, UOI_NAME, szInput, MAX_PATH, &len)) {
DebugOutF(filelog::log_error,("GetUserObjectInformation failed with %d"),GetLastError());
throw FALSE;
}
//compare,if not equal,then switch to the input desktop
if (_tcsicmp(szThread, szInput) != 0)
{
if(!SetThreadDesktop(inputdesk)){
DebugOutF(filelog::log_error,("SetThreadDesktop %s failed with %d"),szInput,GetLastError());
throw FALSE;
}
DebugOutF(filelog::log_info,("switch input desktop %s"),szInput);
res = TRUE;
}
}
catch(BOOL b1)
{
res = b1;
}
if(threaddesk)CloseDesktop(threaddesk);
if(inputdesk)CloseDesktop(inputdesk);
return res;
}
开发者ID:Nillouise,项目名称:WinRobot,代码行数:53,代码来源:SwitchInputDesktop.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: freeLogonSID
void WindowsUser::logout()
{
// Free the buffer for the logon SID.
if (pSid_)
{
freeLogonSID(&pSid_);
}
// Close the handles to the interactive window station and desktop.
if (winstaHandle_)
{
CloseWindowStation(winstaHandle_);
winstaHandle_ = NULL;
}
if (deskHandle_)
{
CloseDesktop(deskHandle_);
deskHandle_ = NULL;
}
// Close the handle to the client's access token.
if (tokenHandle_)
{
RevertToSelf();
CloseHandle(tokenHandle_);
tokenHandle_ = NULL;
}
}
开发者ID:111304037,项目名称:FreeJudger,代码行数:32,代码来源:WindowsUser.cpp
示例10: OpenInputDesktop
LRESULT CIdlePreventDlg::SendWakeEvent(WPARAM wparam, LPARAM lparam)
{
// This ensures we only send wake events while the machine isn't locked. Seems Windows queues some events and sometimes they happen at once as soon as you unlock the computer.
HDESK test = OpenInputDesktop(DF_ALLOWOTHERACCOUNTHOOK, TRUE,DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |DESKTOP_SWITCHDESKTOP |GENERIC_WRITE);
if (test != NULL)
{
if(RDPFriendlyWakeEnabled)
{
keybd_event(VK_RSHIFT,0xB6, KEYEVENTF_KEYUP, 0);
}
else
{
INPUT mouseInput[1];
mouseInput[0].mi.dx = 0;
mouseInput[0].mi.dy = 0;
mouseInput[0].mi.mouseData = 0;
mouseInput[0].mi.dwFlags = MOUSEEVENTF_MOVE;
mouseInput[0].mi.time = 0;
mouseInput[0].mi.dwExtraInfo = NULL;
SendInput(1, mouseInput, sizeof(mouseInput));
SetThreadExecutionState(ES_DISPLAY_REQUIRED);
}
}
CloseDesktop(test);
return 0;
}
开发者ID:enriquein,项目名称:IdlePrevent,代码行数:26,代码来源:IdlePreventDlg.cpp
示例11: 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
示例12: SimulateCtrlAltDelThreadFn
void *
SimulateCtrlAltDelThreadFn(void *context)
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
HDESK winlogon_desk = 0;
// Switch into the Winlogon desktop
if (!vncService::SelectDesktop("Winlogon", &winlogon_desk))
{
vnclog.Print(LL_INTERR, VNCLOG("failed to select logon desktop\n"));
vncTimedMsgBox::Do(
sz_ID_CADERROR,
sz_ID_ULTRAVNC_WARNING,
MB_ICONINFORMATION | MB_OK
);
return FALSE;
}
// 9 April 2008 jdp
// turn off capslock if on
ClearKeyState(VK_CAPITAL);
vnclog.Print(LL_ALL, VNCLOG("generating ctrl-alt-del\n"));
// Fake a hotkey event to any windows we find there.... :(
// Winlogon uses hotkeys to trap Ctrl-Alt-Del...
PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));
// Switch back to our original desktop
if (old_desktop != NULL)
{
vncService::SelectHDESK(old_desktop);
CloseDesktop(winlogon_desk);
}
return NULL;
}
开发者ID:FrantisekKlika,项目名称:UltraVncAsDll,代码行数:34,代码来源:vncservice.cpp
示例13: thread_proc
static DWORD WINAPI thread_proc(void *param)
{
THREAD_DATA* current_data = (THREAD_DATA*)param;
MSG msg;
HDESK hdesk = NULL;
int iwnd;
if(current_data->Desktop)
{
hdesk = CreateDesktopW(current_data->Desktop, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
SetThreadDesktop(hdesk);
}
/* create test window */
current_data->hWnd = CreateWindowW(L"TestClass", L"test", WS_OVERLAPPEDWINDOW,
100, 100, 500, 500, NULL, NULL, 0, NULL);
SetEvent( current_data->StartEvent );
iwnd = get_iwnd(current_data->hWnd);
/* Use MsgWaitForMultipleObjects to let the thread process apcs */
while( GetMessage(&msg, 0,0,0) )
{
if(msg.message > 0 && msg.message < WM_APP && msg.message != WM_TIMER )
record_message(&data[iwnd].cache, iwnd, msg.message, POST, msg.wParam,0);
DispatchMessage(&msg);
}
if(hdesk)
CloseDesktop(hdesk);
return 0;
}
开发者ID:mutoso-mirrors,项目名称:reactos,代码行数:33,代码来源:AttachThreadInput.c
示例14: GuiDeinitFrontEnd
static VOID NTAPI
GuiDeinitFrontEnd(IN OUT PFRONTEND This)
{
PGUI_CONSOLE_DATA GuiData = This->Context;
DPRINT("Send PM_DESTROY_CONSOLE message and wait on hGuiTermEvent...\n");
PostThreadMessageW(GuiData->InputThreadId, PM_DESTROY_CONSOLE, 0, (LPARAM)GuiData);
NtWaitForSingleObject(GuiData->hGuiTermEvent, FALSE, NULL);
DPRINT("hGuiTermEvent set\n");
NtClose(GuiData->hGuiTermEvent);
GuiData->hGuiTermEvent = NULL;
CloseDesktop(GuiData->Desktop); // NtUserCloseDesktop
CloseWindowStation(GuiData->WinSta); // NtUserCloseWindowStation
DPRINT("Destroying icons !! - GuiData->hIcon = 0x%p ; ghDefaultIcon = 0x%p ; GuiData->hIconSm = 0x%p ; ghDefaultIconSm = 0x%p\n",
GuiData->hIcon, ghDefaultIcon, GuiData->hIconSm, ghDefaultIconSm);
if (GuiData->hIcon != NULL && GuiData->hIcon != ghDefaultIcon)
{
DPRINT("Destroy hIcon\n");
DestroyIcon(GuiData->hIcon);
}
if (GuiData->hIconSm != NULL && GuiData->hIconSm != ghDefaultIconSm)
{
DPRINT("Destroy hIconSm\n");
DestroyIcon(GuiData->hIconSm);
}
This->Context = NULL;
DeleteCriticalSection(&GuiData->Lock);
ConsoleFreeHeap(GuiData);
DPRINT("Quit GuiDeinitFrontEnd\n");
}
开发者ID:Strongc,项目名称:reactos,代码行数:34,代码来源:guiterm.c
示例15: 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
示例16: 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
示例17: good2
/* good2() reverses the bodies in the if statement */
static void good2()
{
if(STATIC_CONST_FIVE==5)
{
{
HDESK hDesk;
wchar_t * desktopName = L"DesktopExample";
/* FIX: Call CreateDesktopW() without GENERIC_READ as the 5th parameter to limit access */
hDesk = CreateDesktopW(
desktopName,
NULL,
NULL,
0,
GENERIC_READ,
NULL);
if (hDesk == NULL)
{
printLine("Desktop could not be created");
}
else
{
printLine("Desktop created successfully");
CloseDesktop(hDesk);
}
}
}
}
开发者ID:gpwi970725,项目名称:testJuliet2,代码行数:28,代码来源:CWE284_Improper_Access_Control__w32_wchar_t_CreateDesktop_06.c
示例18: 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
示例19: CWE284_Improper_Access_Control__w32_wchar_t_CreateDesktop_06_bad
void CWE284_Improper_Access_Control__w32_wchar_t_CreateDesktop_06_bad()
{
if(STATIC_CONST_FIVE==5)
{
{
HDESK hDesk;
wchar_t * desktopName = L"DesktopExample";
/* FLAW: Call CreateDesktopW() with GENERIC_ALL as the 5th parameter */
hDesk = CreateDesktopW(
desktopName,
NULL,
NULL,
0,
GENERIC_ALL,
NULL);
if (hDesk == NULL)
{
printLine("Desktop could not be created");
}
else
{
printLine("Desktop created successfully");
CloseDesktop(hDesk);
}
}
}
}
开发者ID:gpwi970725,项目名称:testJuliet2,代码行数:27,代码来源:CWE284_Improper_Access_Control__w32_wchar_t_CreateDesktop_06.c
示例20: good1
/* good1() uses if(STATIC_CONST_FIVE!=5) instead of if(STATIC_CONST_FIVE==5) */
static void good1()
{
if(STATIC_CONST_FIVE!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
{
HDESK hDesk;
wchar_t * desktopName = L"DesktopExample";
/* FIX: Call CreateDesktopW() without GENERIC_READ as the 5th parameter to limit access */
hDesk = CreateDesktopW(
desktopName,
NULL,
NULL,
0,
GENERIC_READ,
NULL);
if (hDesk == NULL)
{
printLine("Desktop could not be created");
}
else
{
printLine("Desktop created successfully");
CloseDesktop(hDesk);
}
}
}
}
开发者ID:gpwi970725,项目名称:testJuliet2,代码行数:33,代码来源:CWE284_Improper_Access_Control__w32_wchar_t_CreateDesktop_06.c
注:本文中的CloseDesktop函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论