FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Terminal Services
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Terminal Services
Posted: Thu Dec 28, 2006 11:21 AM

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.

Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Re: Terminal Services
Posted: Wed Jan 03, 2007 12:57 AM
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.


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" ?


#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.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Terminal Services
Posted: Wed Jan 03, 2007 06:52 AM

Davide,

Thanks,

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Terminal Services
Posted: Wed Jan 03, 2007 11:56 AM
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.

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
Posts: 124
Joined: Mon Nov 14, 2005 10:15 AM
Terminal Services
Posted: Sat Jan 13, 2007 09:46 PM

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

MaurĂ­cio Faria

Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Terminal Services
Posted: Sat Jan 13, 2007 10:51 PM
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
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Urgent please.
Posted: Fri Mar 09, 2007 11:41 AM
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


#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"

HB_FUNC( GETSYSWINDIR )
{
    CHAR Buffer[ MAX_PATH ];

    GetSystemWindowsDirectory( Buffer, MAX_PATH );

    hb_retc( Buffer );
}

#pragma ENDDUMP
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Terminal Services
Posted: Fri Mar 09, 2007 12:38 PM

Davide,

Use dynamic linking:

DLL FUNCTION ...

instead of the FW built in function

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Terminal Services
Posted: Fri Mar 09, 2007 01:12 PM
Antonio,
Antonio Linares wrote:Use dynamic linking:

DLL FUNCTION ...


I cannot have it working without an Harbour exception:

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


what's wrong ?

Thanks,
Davide.
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Terminal Services
Posted: Fri Mar 09, 2007 02:13 PM
what's wrong ?


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

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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Terminal Services
Posted: Fri Mar 09, 2007 02:46 PM

Davide,

It looks fine

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion