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.
the error i got is Error:2 = The system cannot find the file specified.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; }
has any one encountered this before?
regards
deepak


Reply With Quote
