CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2007
    Posts
    90

    Unhappy service: WTS_SESSION_LOGOFF event in SESSION CHANGED

    hello

    i am trying to capture the user information form the service through the HandlerEx Functions while registering.

    i am able to get username and domain name by using WTSQueryInformation () API at WTS_SESSION_LOGON. but when i query at "WTS_SESSION_LOGOFF" nothing comes.

    Code:
    UINT GetUserInfoFromSessionID ( DWORD SessionId, CString & sUserName, CString & sDomainName )
    {
    	UINT nResult = ERROR_SUCCESS;
    
    	LPTSTR  ppBuffer  = NULL;
    	DWORD   pBytesReturned = 0;
    	//query domain
    	if( WTSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE,
    									SessionId,
    									WTSDomainName,
    									&ppBuffer,
    									&pBytesReturned ) )
    	{
    		sDomainName = CString( ppBuffer );
    	}
    	else
    	{
    		nResult = GetLastError();
    		MLOGERR(_T("Failed to Get DomainName From SessionID Error:%d"),nResult);
    	}
    	WTSFreeMemory( ppBuffer );
    	
    	//query UserName
    
    	if( WTSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE,
    		SessionId,
    		WTSUserName,
    		&ppBuffer,
    		&pBytesReturned) )
    	{
    		sUserName = CString( ppBuffer );
    	}
    	else
    	{
    		nResult = GetLastError();
    		MLOGERR(_T("Failed to Get UserName From SessionID Error:%d"),nResult);	
    	}
    
    	WTSFreeMemory( ppBuffer );
    
    	return nResult;
    }
    the error i got is Error:2 = The system cannot find the file specified.


    has any one encountered this before?

    regards
    deepak

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: service: WTS_SESSION_LOGOFF event in SESSION CHANGED

    Hm.. perhaps on logoff, the tokeis invalid and domain name and user name doesn't make sense anymore.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured