Exemplo n.º 1
0
DWORD apiGetConsoleSessionID()
{
	DWORD nSessionId = 0;
	DWORD (WINAPI* wtsGetActiveConsoleSessionId)(void) = NULL;
	MModule kernel32(L"kernel32.dll");
	if (kernel32.GetProcAddress("WTSGetActiveConsoleSessionId", wtsGetActiveConsoleSessionId))
	{
		nSessionId = wtsGetActiveConsoleSessionId();
	}
	return nSessionId;
}
Exemplo n.º 2
0
static DWORD WINAPI initializeWTSGetActiveConsoleSessionId(void)
{
    HMODULE hModule = GetModuleHandle(_T("kernel32.dll"));
    if (!hModule) {
        return FALSE;
    }
    WTSGetActiveConsoleSessionId_t proc =
        reinterpret_cast<WTSGetActiveConsoleSessionId_t>(
            GetProcAddress(hModule, "WTSGetActiveConsoleSessionId"));
    if (proc) {
        wtsGetActiveConsoleSessionId = proc;
        return wtsGetActiveConsoleSessionId();
    } else {
        return 0;
    }
}