Terminal Services

Terminal Services

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

Re: Terminal Services

Postby Davide » 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.


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

Postby Antonio Linares » Wed Jan 03, 2007 6:52 am

Davide,

Thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Davide » 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.

Code: Select all  Expand view
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

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

Postby concentra » Sat Jan 13, 2007 9:46 pm

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

Maurício Faria
User avatar
concentra
 
Posts: 124
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

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

Urgent please.

Postby Davide » 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


Code: Select all  Expand view
#pragma BEGINDUMP

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

HB_FUNC( GETSYSWINDIR )
{
    CHAR Buffer[ MAX_PATH ];

    GetSystemWindowsDirectory( Buffer, MAX_PATH );

    hb_retc( Buffer );
}

#pragma ENDDUMP

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

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Davide » Fri Mar 09, 2007 1:12 pm

Antonio,
Antonio Linares wrote:Use dynamic linking:

DLL FUNCTION ...


I cannot have it working without an Harbour exception:

Code: Select all  Expand view
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

Postby Davide » Fri Mar 09, 2007 2:13 pm

what's wrong ?


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

Code: Select all  Expand view
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
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Postby Antonio Linares » Fri Mar 09, 2007 2:46 pm

Davide,

It looks fine
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 64 guests

cron