How do I use WFAPI.dll with VB to get client name - Terminal Server client 
Author Message
 How do I use WFAPI.dll with VB to get client name - Terminal Server client

I apologize in advance for cross-posting, but I have no idea where the ideal
place to ask this question would be.

My company uses a Visual Basic application that up until now has been run on
Windows 95/98 workstations.  As part of the programs configuration, it reads
the PC name from the system using the kernel32 api call GetComputerNameA to
return the computer name.  This is then used to lookup configuration
information in an access database on the network.

Here is the problem: we are getting ready to move this application among
others to Windows Terminal Server v4 with Citrix Metaframe, so now I have to
know the name of the client that is opening the application.  If you use the
GetComputerNameA api call you always get the server's PC name not the
clients.

The Metaframe product includes a dll called wfapi.dll  It uses almost exact
syntax as wtsapi.dll that is supposedly provided by MS (though I have not
found it yet, in spite of the fact that I have WTS sp4 installed).

I am trying to use the WFOpenServer function to open a connection to the
server, followed by WFQuerySessionInformation to get the WFClientName so
that I can look up the clientname in the access database just as we do now.

So, if anyone has used the wfapi or wtsapi in VB, please let me know how you
got it to work, or if you can just figure it out from the info I have
provided, please do.

Because no matter what I try, and I have tried a couple of different ways of
declaring/calling this, I always get Null back for ClientName.  Which I
believe indicates a failure to get the clientname.

============================================================================
=================
Here are the declares that I have been using:

Option Explicit

Declare Function WFOpenServer Lib "wfapi" Alias "WFOpenServerA" (ByVal
pServerName As String) As Long
Declare Function WFQuerySessionInformation Lib "wfapi" Alias
"WFQuerySessionInformationA" (ByVal hServer As Long, ByVal SessionID As
Long, ByVal WFInfoClass As String, ByVal ppBuffer As Any, pBytesReturned As
Long) As Long
Declare Sub WFCloseServer Lib "wfapi" (ByVal hServer As Long)

============================================================================
=================
And here is the routine that I have been using to try and get the value:

Function GetWTSClientName() As String

    Dim Dummy As Long
    Dim ClientName As String
    Dim hServer As Long
    Dim nLen As Long
    Dim pServer As String

    ClientName = Space(16)
    nLen = Len(ClientName)
    pServer = "SERVER1"
    hServer = WFOpenServer(pServer)
    Dummy = WFQuerySessionInformation(hServer, -1, "WFClientName",
ClientName, nLen)
    GetWTSClientName = ClientName

End Function

============================================================================
=================
Here are the 'C' calling conventions, which are the only documentation I can
find on how to use these functions

WFOpenServer

Open a handle to the specified Citrix server.

Calling Convention

HANDLE WINAPI WFOpenServerA(
    IN LPSTR pServerName
    );

WFQuerySessionInformation

Return information about the specified session on the specified Citrix
server.

Calling Convention

BOOL WINAPI WFQuerySessionInformationA(
    IN HANDLE hServer,
    IN DWORD SessionId,
    IN WF_INFO_CLASS WFInfoClass,
    OUT LPSTR * ppBuffer,
    OUT DWORD * pBytesReturned
    );

============================================================================
===================

Thanks in advance,
Chris Riley




Fri, 12 Apr 2002 03:00:00 GMT  
 How do I use WFAPI.dll with VB to get client name - Terminal Server client


Quote:
> I apologize in advance for cross-posting, but I have no idea where the ideal
> place to ask this question would be.

> My company uses a Visual Basic application that up until now has been run on
> Windows 95/98 workstations.  As part of the programs configuration, it reads
> the PC name from the system..

<snip>

Quote:
> so now I have to
> know the name of the client that is opening the application.

Did you check for simple DOS variables.. you'll find one called CLIENTNAME

--
Andrew Carpenter
Computing Technician
Cirencester College

ICQ : 20885021



Sat, 13 Apr 2002 03:00:00 GMT  
 How do I use WFAPI.dll with VB to get client name - Terminal Server client
BTW, if you check the MSDN KB, you'll find an article that states that VB is
not supported on Terminal Server (yet).

--

Randy Birch, MVP Visual Basic

http://www.mvps.org/vbnet/
http://www.mvps.org/ccrp/

Please correspond only using the newsgroups so all can benefit.

| I think you want to try wtsapi32.dll - I'll be trying it in a few
| minutes using your code.
|
| Good luck,
|
| Cade Roux
|


| > I apologize in advance for cross-posting, but I have no idea where
| the ideal
| > place to ask this question would be.
| >
| > My company uses a Visual Basic application that up until now has been
| run on
| > Windows 95/98 workstations.  As part of the programs configuration,
| it reads
| > the PC name from the system using the kernel32 api call
| GetComputerNameA to
| > return the computer name.  This is then used to lookup configuration
| > information in an access database on the network.
| >
| > Here is the problem: we are getting ready to move this application
| among
| > others to Windows Terminal Server v4 with Citrix Metaframe, so now I
| have to
| > know the name of the client that is opening the application.  If you
| use the
| > GetComputerNameA api call you always get the server's PC name not the
| > clients.
| >
| > The Metaframe product includes a dll called wfapi.dll  It uses almost
| exact
| > syntax as wtsapi.dll that is supposedly provided by MS (though I have
| not
| > found it yet, in spite of the fact that I have WTS sp4 installed).
| >
| > I am trying to use the WFOpenServer function to open a connection to
| the
| > server, followed by WFQuerySessionInformation to get the WFClientName
| so
| > that I can look up the clientname in the access database just as we
| do now.
| >
| > So, if anyone has used the wfapi or wtsapi in VB, please let me know
| how you
| > got it to work, or if you can just figure it out from the info I have
| > provided, please do.
| >
| > Because no matter what I try, and I have tried a couple of different
| ways of
| > declaring/calling this, I always get Null back for ClientName.  Which
| I
| > believe indicates a failure to get the clientname.
| >
| >
| ========================================================================
| ====
| > =================
| > Here are the declares that I have been using:
| >
| > Option Explicit
| >
| > Declare Function WFOpenServer Lib "wfapi" Alias "WFOpenServerA" (ByVal
| > pServerName As String) As Long
| > Declare Function WFQuerySessionInformation Lib "wfapi" Alias
| > "WFQuerySessionInformationA" (ByVal hServer As Long, ByVal SessionID
| As
| > Long, ByVal WFInfoClass As String, ByVal ppBuffer As Any,
| pBytesReturned As
| > Long) As Long
| > Declare Sub WFCloseServer Lib "wfapi" (ByVal hServer As Long)
| >
| >
| ========================================================================
| ====
| > =================
| > And here is the routine that I have been using to try and get the
| value:
| >
| > Function GetWTSClientName() As String
| >
| >     Dim Dummy As Long
| >     Dim ClientName As String
| >     Dim hServer As Long
| >     Dim nLen As Long
| >     Dim pServer As String
| >
| >     ClientName = Space(16)
| >     nLen = Len(ClientName)
| >     pServer = "SERVER1"
| >     hServer = WFOpenServer(pServer)
| >     Dummy = WFQuerySessionInformation(hServer, -1, "WFClientName",
| > ClientName, nLen)
| >     GetWTSClientName = ClientName
| >
| > End Function
| >
| >
| ========================================================================
| ====
| > =================
| > Here are the 'C' calling conventions, which are the only
| documentation I can
| > find on how to use these functions
| >
| > WFOpenServer
| >
| > Open a handle to the specified Citrix server.
| >
| > Calling Convention
| >
| > HANDLE WINAPI WFOpenServerA(
| >     IN LPSTR pServerName
| >     );
| >
| > WFQuerySessionInformation
| >
| > Return information about the specified session on the specified Citrix
| > server.
| >
| > Calling Convention
| >
| > BOOL WINAPI WFQuerySessionInformationA(
| >     IN HANDLE hServer,
| >     IN DWORD SessionId,
| >     IN WF_INFO_CLASS WFInfoClass,
| >     OUT LPSTR * ppBuffer,
| >     OUT DWORD * pBytesReturned
| >     );
| >
| >
| ========================================================================
| ====
| > ===================
| >
| > Thanks in advance,
| > Chris Riley


| >
| >
|
|
| Sent via Deja.com http://www.deja.com/
| Before you buy.



Fri, 10 May 2002 03:00:00 GMT  
 How do I use WFAPI.dll with VB to get client name - Terminal Server client
I think you want to try wtsapi32.dll - I'll be trying it in a few
minutes using your code.

Good luck,

Cade Roux



Quote:
> I apologize in advance for cross-posting, but I have no idea where
the ideal
> place to ask this question would be.

> My company uses a Visual Basic application that up until now has been
run on
> Windows 95/98 workstations.  As part of the programs configuration,
it reads
> the PC name from the system using the kernel32 api call
GetComputerNameA to
> return the computer name.  This is then used to lookup configuration
> information in an access database on the network.

> Here is the problem: we are getting ready to move this application
among
> others to Windows Terminal Server v4 with Citrix Metaframe, so now I
have to
> know the name of the client that is opening the application.  If you
use the
> GetComputerNameA api call you always get the server's PC name not the
> clients.

> The Metaframe product includes a dll called wfapi.dll  It uses almost
exact
> syntax as wtsapi.dll that is supposedly provided by MS (though I have
not
> found it yet, in spite of the fact that I have WTS sp4 installed).

> I am trying to use the WFOpenServer function to open a connection to
the
> server, followed by WFQuerySessionInformation to get the WFClientName
so
> that I can look up the clientname in the access database just as we
do now.

> So, if anyone has used the wfapi or wtsapi in VB, please let me know
how you
> got it to work, or if you can just figure it out from the info I have
> provided, please do.

> Because no matter what I try, and I have tried a couple of different
ways of
> declaring/calling this, I always get Null back for ClientName.  Which
I
> believe indicates a failure to get the clientname.

========================================================================
====

- Show quoted text -

Quote:
> =================
> Here are the declares that I have been using:

> Option Explicit

> Declare Function WFOpenServer Lib "wfapi" Alias "WFOpenServerA" (ByVal
> pServerName As String) As Long
> Declare Function WFQuerySessionInformation Lib "wfapi" Alias
> "WFQuerySessionInformationA" (ByVal hServer As Long, ByVal SessionID
As
> Long, ByVal WFInfoClass As String, ByVal ppBuffer As Any,
pBytesReturned As
> Long) As Long
> Declare Sub WFCloseServer Lib "wfapi" (ByVal hServer As Long)

========================================================================
====

- Show quoted text -

Quote:
> =================
> And here is the routine that I have been using to try and get the
value:

> Function GetWTSClientName() As String

>     Dim Dummy As Long
>     Dim ClientName As String
>     Dim hServer As Long
>     Dim nLen As Long
>     Dim pServer As String

>     ClientName = Space(16)
>     nLen = Len(ClientName)
>     pServer = "SERVER1"
>     hServer = WFOpenServer(pServer)
>     Dummy = WFQuerySessionInformation(hServer, -1, "WFClientName",
> ClientName, nLen)
>     GetWTSClientName = ClientName

> End Function

========================================================================
====

- Show quoted text -

Quote:
> =================
> Here are the 'C' calling conventions, which are the only
documentation I can
> find on how to use these functions

> WFOpenServer

> Open a handle to the specified Citrix server.

> Calling Convention

> HANDLE WINAPI WFOpenServerA(
>     IN LPSTR pServerName
>     );

> WFQuerySessionInformation

> Return information about the specified session on the specified Citrix
> server.

> Calling Convention

> BOOL WINAPI WFQuerySessionInformationA(
>     IN HANDLE hServer,
>     IN DWORD SessionId,
>     IN WF_INFO_CLASS WFInfoClass,
>     OUT LPSTR * ppBuffer,
>     OUT DWORD * pBytesReturned
>     );

========================================================================
====

Quote:
> ===================

> Thanks in advance,
> Chris Riley



Sent via Deja.com http://www.deja.com/
Before you buy.


Sat, 11 May 2002 03:00:00 GMT  
 How do I use WFAPI.dll with VB to get client name - Terminal Server client
FWIW, I got it working using a DLL created in VC++6 (install the latest
Platform SDK to get the wtsapi32.h and wtsapi32.lib) and then calling
the DLL from VB (mainly because of the awkward structures use in the
API)

Good Luck,

Cade Roux



Quote:
> I apologize in advance for cross-posting, but I have no idea where
the ideal
> place to ask this question would be.

> My company uses a Visual Basic application that up until now has been
run on
> Windows 95/98 workstations.  As part of the programs configuration,
it reads
> the PC name from the system using the kernel32 api call
GetComputerNameA to
> return the computer name.  This is then used to lookup configuration
> information in an access database on the network.

> Here is the problem: we are getting ready to move this application
among
> others to Windows Terminal Server v4 with Citrix Metaframe, so now I
have to
> know the name of the client that is opening the application.  If you
use the
> GetComputerNameA api call you always get the server's PC name not the
> clients.

> The Metaframe product includes a dll called wfapi.dll  It uses almost
exact
> syntax as wtsapi.dll that is supposedly provided by MS (though I have
not
> found it yet, in spite of the fact that I have WTS sp4 installed).

> I am trying to use the WFOpenServer function to open a connection to
the
> server, followed by WFQuerySessionInformation to get the WFClientName
so
> that I can look up the clientname in the access database just as we
do now.

> So, if anyone has used the wfapi or wtsapi in VB, please let me know
how you
> got it to work, or if you can just figure it out from the info I have
> provided, please do.

> Because no matter what I try, and I have tried a couple of different
ways of
> declaring/calling this, I always get Null back for ClientName.  Which
I
> believe indicates a failure to get the clientname.

========================================================================
====

- Show quoted text -

Quote:
> =================
> Here are the declares that I have been using:

> Option Explicit

> Declare Function WFOpenServer Lib "wfapi" Alias "WFOpenServerA" (ByVal
> pServerName As String) As Long
> Declare Function WFQuerySessionInformation Lib "wfapi" Alias
> "WFQuerySessionInformationA" (ByVal hServer As Long, ByVal SessionID
As
> Long, ByVal WFInfoClass As String, ByVal ppBuffer As Any,
pBytesReturned As
> Long) As Long
> Declare Sub WFCloseServer Lib "wfapi" (ByVal hServer As Long)

========================================================================
====

- Show quoted text -

Quote:
> =================
> And here is the routine that I have been using to try and get the
value:

> Function GetWTSClientName() As String

>     Dim Dummy As Long
>     Dim ClientName As String
>     Dim hServer As Long
>     Dim nLen As Long
>     Dim pServer As String

>     ClientName = Space(16)
>     nLen = Len(ClientName)
>     pServer = "SERVER1"
>     hServer = WFOpenServer(pServer)
>     Dummy = WFQuerySessionInformation(hServer, -1, "WFClientName",
> ClientName, nLen)
>     GetWTSClientName = ClientName

> End Function

========================================================================
====

- Show quoted text -

Quote:
> =================
> Here are the 'C' calling conventions, which are the only
documentation I can
> find on how to use these functions

> WFOpenServer

> Open a handle to the specified Citrix server.

> Calling Convention

> HANDLE WINAPI WFOpenServerA(
>     IN LPSTR pServerName
>     );

> WFQuerySessionInformation

> Return information about the specified session on the specified Citrix
> server.

> Calling Convention

> BOOL WINAPI WFQuerySessionInformationA(
>     IN HANDLE hServer,
>     IN DWORD SessionId,
>     IN WF_INFO_CLASS WFInfoClass,
>     OUT LPSTR * ppBuffer,
>     OUT DWORD * pBytesReturned
>     );

========================================================================
====

Quote:
> ===================

> Thanks in advance,
> Chris Riley



Sent via Deja.com http://www.deja.com/
Before you buy.


Sat, 11 May 2002 03:00:00 GMT  
 How do I use WFAPI.dll with VB to get client name - Terminal Server client
VB the application/IDE is not supported running on Terminal Server.
Applications which happen to be developed in VB are supported as much
as any other third party applications - i.e. by the developer and any
help they can get from MS.

Cade Roux



Quote:
> BTW, if you check the MSDN KB, you'll find an article that states
that VB is
> not supported on Terminal Server (yet).

> --

> Randy Birch, MVP Visual Basic

> http://www.mvps.org/vbnet/
> http://www.mvps.org/ccrp/

> Please correspond only using the newsgroups so all can benefit.


> | I think you want to try wtsapi32.dll - I'll be trying it in a few
> | minutes using your code.
> |
> | Good luck,
> |
> | Cade Roux
> |


> | > I apologize in advance for cross-posting, but I have no idea where
> | the ideal
> | > place to ask this question would be.
> | >
> | > My company uses a Visual Basic application that up until now has
been
> | run on
> | > Windows 95/98 workstations.  As part of the programs
configuration,
> | it reads
> | > the PC name from the system using the kernel32 api call
> | GetComputerNameA to
> | > return the computer name.  This is then used to lookup
configuration
> | > information in an access database on the network.
> | >
> | > Here is the problem: we are getting ready to move this application
> | among
> | > others to Windows Terminal Server v4 with Citrix Metaframe, so
now I
> | have to
> | > know the name of the client that is opening the application.  If
you
> | use the
> | > GetComputerNameA api call you always get the server's PC name not
the
> | > clients.
> | >
> | > The Metaframe product includes a dll called wfapi.dll  It uses
almost
> | exact
> | > syntax as wtsapi.dll that is supposedly provided by MS (though I
have
> | not
> | > found it yet, in spite of the fact that I have WTS sp4 installed).
> | >
> | > I am trying to use the WFOpenServer function to open a connection
to
> | the
> | > server, followed by WFQuerySessionInformation to get the
WFClientName
> | so
> | > that I can look up the clientname in the access database just as
we
> | do now.
> | >
> | > So, if anyone has used the wfapi or wtsapi in VB, please let me
know
> | how you
> | > got it to work, or if you can just figure it out from the info I
have
> | > provided, please do.
> | >
> | > Because no matter what I try, and I have tried a couple of
different
> | ways of
> | > declaring/calling this, I always get Null back for ClientName.
Which
> | I
> | > believe indicates a failure to get the clientname.
> | >
> | >
> |

========================================================================

- Show quoted text -

Quote:
> | ====
> | > =================
> | > Here are the declares that I have been using:
> | >
> | > Option Explicit
> | >
> | > Declare Function WFOpenServer Lib "wfapi" Alias "WFOpenServerA"
(ByVal
> | > pServerName As String) As Long
> | > Declare Function WFQuerySessionInformation Lib "wfapi" Alias
> | > "WFQuerySessionInformationA" (ByVal hServer As Long, ByVal
SessionID
> | As
> | > Long, ByVal WFInfoClass As String, ByVal ppBuffer As Any,
> | pBytesReturned As
> | > Long) As Long
> | > Declare Sub WFCloseServer Lib "wfapi" (ByVal hServer As Long)
> | >
> | >
> |

========================================================================

- Show quoted text -

Quote:
> | ====
> | > =================
> | > And here is the routine that I have been using to try and get the
> | value:
> | >
> | > Function GetWTSClientName() As String
> | >
> | >     Dim Dummy As Long
> | >     Dim ClientName As String
> | >     Dim hServer As Long
> | >     Dim nLen As Long
> | >     Dim pServer As String
> | >
> | >     ClientName = Space(16)
> | >     nLen = Len(ClientName)
> | >     pServer = "SERVER1"
> | >     hServer = WFOpenServer(pServer)
> | >     Dummy = WFQuerySessionInformation(hServer, -1, "WFClientName",
> | > ClientName, nLen)
> | >     GetWTSClientName = ClientName
> | >
> | > End Function
> | >
> | >
> |

========================================================================

- Show quoted text -

Quote:
> | ====
> | > =================
> | > Here are the 'C' calling conventions, which are the only
> | documentation I can
> | > find on how to use these functions
> | >
> | > WFOpenServer
> | >
> | > Open a handle to the specified Citrix server.
> | >
> | > Calling Convention
> | >
> | > HANDLE WINAPI WFOpenServerA(
> | >     IN LPSTR pServerName
> | >     );
> | >
> | > WFQuerySessionInformation
> | >
> | > Return information about the specified session on the specified
Citrix
> | > server.
> | >
> | > Calling Convention
> | >
> | > BOOL WINAPI WFQuerySessionInformationA(
> | >     IN HANDLE hServer,
> | >     IN DWORD SessionId,
> | >     IN WF_INFO_CLASS WFInfoClass,
> | >     OUT LPSTR * ppBuffer,
> | >     OUT DWORD * pBytesReturned
> | >     );
> | >
> | >
> |

========================================================================

Quote:
> | ====
> | > ===================
> | >
> | > Thanks in advance,
> | > Chris Riley


> | >
> | >
> |
> |
> | Sent via Deja.com http://www.deja.com/
> | Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Sat, 11 May 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How do I use WFAPI.dll with VB to get client name - Terminal Server client

2. Getting the Terminal Services Client Machine Name

3. Terminal Server - Client Name

4. Terminal Server Client Name

5. Doing DCC (direct client to client) tranfers with a VB program

6. API call to get Netware user name from 32-bit client using MSFT Client for Netware

7. API call to get Netware user name from 32-bit client using MSFT Client for Netware

8. fat client (MSMQ, VB Program) or thin client (ASP page then have Web server use MSMQ)

9. Terminal Service Client Name/User

10. Detecting disconnected Terminal Server Client

11. Terminal Server Problem / Beep on the client machine

12. Terminal server advanced client

 

 
Powered by phpBB® Forum Software