winsta0,session,desktop,winlogon,default

A window station is an objectthat contains a clipboard, a set of global atoms and a group ofdesktop objects. Only one window station per session is permittedto interact with the user. This window station is named "Winsta0."Every window station belongs to a session. Session 0 is the sessionwhere services run and typically represents the console(pre-Vista). Any other sessions (Session 1, Session 2, etc) aretypically remote desktops / terminal server sessions, or sessionsattached to the console via Fast User Switching. So to summarize,sessions contain one or more window stations, and window stationscontain one or more desktops.

     You can picture the relationshipdescribed above as a tree. Below is an example of this desktop treeon a typical system:

- Session 0

| |

| ---- WinSta0 (interactive window station)

| | |

| | ---- Default (desktop)

| | |

| | ---- Disconnect (desktop)

| | |

| | ---- Winlogon (desktop)

| |

| ---- Service-0x0-3e7$ (non-interactive window station)

| | |

| | ---- Default (desktop)

| |

| ---- Service-0x0-3e4$ (non-interactive window station)

| | |

| | ---- Default (desktop)

| |

| ---- SAWinSta (non-interactive window station)

| | |

| | ---- SADesktop (desktop)

| |

- Session 1

| |

| ---- WinSta0 (interactive window station)

| | |

| | ---- Default (desktop)

| | |

| | ---- Disconnect (desktop)

| | |

| | ---- Winlogon (desktop)

| |

- Session 2

|

---- WinSta0 (interactive window station)

|

---- Default (desktop)

|

---- Disconnect (desktop)

|

---- Winlogon (desktop)

----to be continued


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#include "mainwindow.h" #include <QApplication> #include <windows.h> #include <wtsapi32.h> #pragma comment(lib, "Wtsapi32.lib") int main(int argc, char *argv[]) { QApplication a(argc, argv); HANDLE hToken = NULL; DWORD dwSessionId = WTSGetActiveConsoleSessionId(); if (!WTSQueryUserToken(dwSessionId, &hToken)) { QMessageBox::warning(nullptr, QStringLiteral("错误"), QStringLiteral("获取用户令牌失败!")); return -1; } HANDLE mutex = ::CreateMutex(Q_NULLPTR, true, (LPCWSTR)qApp->applicationName().toStdWString().c_str()); if (GetLastError() == ERROR_ALREADY_EXISTS) { QMessageBox warningBox(QMessageBox::Warning, QStringLiteral("警告"), QStringLiteral("程序[文本数据同步服务端]只能运行一个!")); warningBox.setButtonText(QMessageBox::Ok, QStringLiteral("确定")); warningBox.setStandardButtons(QMessageBox::Ok); warningBox.exec(); ::CloseHandle(mutex); return 0; } else { ::ReleaseMutex(mutex); } STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); si.lpDesktop = (LPWSTR)L"winsta0\\default"; PROCESS_INFORMATION pi; ZeroMemory(&pi, sizeof(pi)); if (!CreateProcessAsUser(hToken, NULL, (LPWSTR)qApp->applicationFilePath().toStdWString().data(), NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi)) { QMessageBox::warning(nullptr, QStringLiteral("错误"), QStringLiteral("创建进程失败!")); CloseHandle(hToken); return -1; } CloseHandle(hToken); MainWindow w; w.show(); return a.exec(); } 以上QT C++代码会报出以下错误: D:\QtProject\DataServer\main.cpp:-1: error: undefined reference to `WTSQueryUserToken@8' collect2.exe:-1: error: error: ld returned 1 exit status 请修复后给我完整代码
05-30

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值