Terminal Services
Terminal Services
Hello all,
1) is there a function which tells me if Terminal Services are installed on a server in application mode ?
I know OS_IsWTSClient() to retrieve if the application is running on a Terminal session, but I would need to know it on the server console.
2) When Terminal Services are installed, the GetWinDir() function retrieves a different directory for each user: "C:\Documents and Settings\<user name>\WINDOWS"
Is it possible to retrieve which is the real Windows directory, typically "C:\WINDOWS" ?
Thank you,
Davide.
1) is there a function which tells me if Terminal Services are installed on a server in application mode ?
I know OS_IsWTSClient() to retrieve if the application is running on a Terminal session, but I would need to know it on the server console.
2) When Terminal Services are installed, the GetWinDir() function retrieves a different directory for each user: "C:\Documents and Settings\<user name>\WINDOWS"
Is it possible to retrieve which is the real Windows directory, typically "C:\WINDOWS" ?
Thank you,
Davide.
Re: Terminal Services
Solved. I hope this could help someone else:
Hi,
Davide.
1) is there a function which tells me if Terminal Services are installed on a server in application mode ?
I know OS_IsWTSClient() to retrieve if the application is running on a Terminal session, but I would need to know it on the server console.
Code: Select all
Function IsWtsEnabled()
Return ( GetWinDir() <> GetSystemWindowsDirectory() )
2) When Terminal Services are installed, the GetWinDir() function retrieves a different directory for each user: "C:\Documents and Settings\<user name>\WINDOWS"
Is it possible to retrieve which is the real Windows directory, typically "C:\WINDOWS" ?
Code: Select all
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
HB_FUNC( GETSYSTEMWINDOWSDIRECTORY )
{
CHAR Buffer[ MAX_PATH ];
GetSystemWindowsDirectory( Buffer, MAX_PATH );
hb_retc( Buffer );
}
#pragma ENDDUMP
Davide.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
As it works only for Terminal Server enabled OS's (no 9x/ME), here is a function which takes care of the different cases.
I do not have a NT4 Terminal Server to test. If you can test it ...
Hi,
Davide.
I do not have a NT4 Terminal Server to test. If you can test it ...
Hi,
Davide.
Code: Select all
Function RealWinDir()
Local cDir,i
If IsWin95() // No Terminal Services
cDir:=GetWinDir()
Else
IF ( "NT" $ cWinVersion() ) // Windows NT is different
cDir:=GetSysDir()
i:=RAT("\system32",Lower(cDir)) ; cDir:=Left(cDir,i-1)
Else
cDir:=GetSysWinDir() // ok XP,2000,2003
Endif
Endif
Return cDir
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
HB_FUNC( GETSYSWINDIR )
{
CHAR Buffer[ MAX_PATH ];
GetSystemWindowsDirectory( Buffer, MAX_PATH );
hb_retc( Buffer );
}
#pragma ENDDUMP
Urgent please.
On Windows 98 the EXE does not start because GetWindowsSystemDirectoryA is not included in Kernel32.dll (even thought in RealWinDir() it's not called in Win98)
How can I do to exclude that part if I'm on 98 (or to use the GetWinDir() instead) ?
Urgent please !
Thanks
Davide
How can I do to exclude that part if I'm on 98 (or to use the GetWinDir() instead) ?
Urgent please !
Thanks
Davide
Code: Select all
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
HB_FUNC( GETSYSWINDIR )
{
CHAR Buffer[ MAX_PATH ];
GetSystemWindowsDirectory( Buffer, MAX_PATH );
hb_retc( Buffer );
}
#pragma ENDDUMP
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Antonio,
what's wrong ?
Thanks,
Davide.
I cannot have it working without an Harbour exception:Antonio Linares wrote:Use dynamic linking:
DLL FUNCTION ...
Code: Select all
DLL32 Function GetSysWinDir( lpBuffer AS LPSTR , uSize AS DWORD ) AS LPSTR ;
PASCAL FROM "GetSystemWindowsDirectoryA" LIB "kernel32.dll"
Thanks,
Davide.
ok, I've found it. Here's the function:what's wrong ?
Code: Select all
FUNCTION GetSysWinDir()
Local cBuffer := Space(261)
Local nLen
nLen := GetSystemWindowsDirectory( @cBuffer, Len(cBuffer) )
RETURN Left(cBuffer, nLen)
//----------------------------------------------------------------------------//
DLL32 Function GetSystemWindowsDirectory( lpBuffer AS LPSTR , uSize AS DWORD ) AS DWORD ;
PASCAL FROM "GetSystemWindowsDirectoryA" LIB "kernel32.dll"
//----------------------------------------------------------------------------//
Regards,
Davide
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: