Terminal Services

Post Reply
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Terminal Services

Post by Davide »

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.
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Re: Terminal Services

Post by Davide »

Solved. I hope this could help someone else:
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
Hi,
Davide.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Davide,

Thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post by Davide »

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.

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

User avatar
concentra
Posts: 107
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Post by concentra »

Davide, did you have success in getting the IP address of the TS client ?

Maurício Faria
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post by Davide »

Maurício,
concentra wrote:Davide, did you have success in getting the IP address of the TS client ?
I don't need that info. In order to recognize the clients I use NetName(.t.)

Hi,
Davide
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Urgent please.

Post by Davide »

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

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

User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Davide,

Use dynamic linking:

DLL FUNCTION ...

instead of the FW built in function
regards, saludos

Antonio Linares
www.fivetechsoft.com
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post by Davide »

Antonio,
Antonio Linares wrote:Use dynamic linking:

DLL FUNCTION ...
I cannot have it working without an Harbour exception:

Code: Select all

DLL32 Function GetSysWinDir( lpBuffer AS LPSTR , uSize AS DWORD ) AS LPSTR ;
                             PASCAL FROM "GetSystemWindowsDirectoryA" LIB "kernel32.dll"
what's wrong ?

Thanks,
Davide.
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post by Davide »

what's wrong ?
ok, I've found it. Here's the function:

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"

//----------------------------------------------------------------------------//
I'm going to test it on the different OS's, unless you already see something wrong in it.

Regards,
Davide
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Davide,

It looks fine
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply