Thank you for your help.
/**************************************************/
CString GetTSClientAddress( DWORD sessionID /* = (DWORD) -1*/ )
{
LPTSTR ppBuffer = NULL;
DWORD pBytesReturned = 0;
PWTS_CLIENT_ADDRESS pWTSCA = NULL;
if (sessionID == (DWORD) -1) sessionID = WTS_CURRENT_SESSION;
CString clientFamilyAndAddress; clientFamilyAndAddress.Empty();
LPWTSQuerySessionInformation pWTSQuerySessionInformation = NULL;
LPWTSFreeMemory pWTSFreeMemory = NULL;
HINSTANCE WTSApiDll = LoadLibrary("WTSAPI32.DLL");
if (WTSApiDll)
{
pWTSQuerySessionInformation =
(LPWTSQuerySessionInformation) GetProcAddress(WTSApiDll,
"WTSQuerySessionInformationA");
pWTSFreeMemory = (LPWTSFreeMemory) GetProcAddress(WTSApiDll,
"WTSFreeMemory");
}
if (WTSApiDll == NULL || pWTSQuerySessionInformation == NULL ||
pWTSFreeMemory == NULL)
{
if (WTSApiDll != NULL) FreeLibrary(WTSApiDll);
if (IsSystemTerminalServer())
{
AfxMessageBox("Unable to load WTSAPI32.DLL.\r\nPlease contact support");
}
return clientFamilyAndAddress;
}
BOOL b = (*pWTSQuerySessionInformation)( WTS_CURRENT_SERVER_HANDLE,
sessionID,
WTSClientAddress,
&ppBuffer,
&pBytesReturned);
if (b) {
/* other instructions */
(*pWTSFreeMemory)( ppBuffer );
}
else
{
if (IsSystemTerminalServer()){
DWORD dwError = GetLastError();
CString csError;
ErrorToString(dwError, csError);
csError.Insert(0,"Query TSE client info failed.\r\n");
AfxMessageBox(csError, MB_ICONINFORMATION);
}
}
if (WTSApiDll != NULL) FreeLibrary(WTSApiDll);
return clientFamilyAndAddress;
}
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"a.aka" <aa...@discussions.microsoft.com> wrote in message
news:851F0502-D29E-4530...@microsoft.com...
Thanks
Soo Kuan
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"a.aka" <aa...@discussions.microsoft.com> wrote in message
news:7404053F-3969-447B...@microsoft.com...
My application supports all windows platform since Windows 95. And to make
sure that using WTSAPI32.DLL will not cause trouble, I make a LoadLibrary and
if this call fails, I suppose that the platform doesn't support Terminal
services API. The problem I describe is that : on some Windows 2000 Server
machine, the LoadLibrary succeeded but when I call the
"WTSQuerySessionInformation" function (after having done a GetProcAddress),
it returns a curious error : ERROR_APP_WRONG_OS. I was able to make my
application run on another Windows 2000 Server. I'd like to know if there is
a minimum requirement to have WTSAPI32.DLL work on Windows 2000 (like service
pack or other thing).
Thank you.
A.AKA
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"a.aka" <aa...@discussions.microsoft.com> wrote in message
news:1D9DFEBA-4DF6-4025...@microsoft.com...