473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Licencias programa en remoto

Hola buenos dias,

Estoy haciendo un programa en VB 6 que se ejecutara en remoto con Terminal
Server o con CITRIX. Pero tengo que hacer un control de licencias, pensava
en hacer un control por el ordenador que està visualizando el programa. És
posible saber la dirección MAC o el serial del disco duro de ordenador que
esta visualizando el programa? Alguien tiene alguna sugerencia para que solo
el ordenador que se ha licenciado lo pueda ver?

Se agradece cualquier sugerencia,

Saludos cordiales,

SilviaLl.
Dec 7 '07 #1
1 1571
Hello SilviaLl

Your post is 2 times wrong in terms of "Language"

1. The programming language , as this is newgroup has a dotnet prefix it is
not a "classic" group i recomend for VB6
microsoft.public.vb.general.discussion as this group seems to be pretty
active

2. The language in nwich you ask your question newgroup without anny
language identifiers ( nl for dutch , it for italian , es for spanish
etc etc etc ) are so called international groups the comunication language
in these groups is the English language .
if i understand you correctly you need a way to detect the clients starting
your program on a terminal server written in VB6
this might help you as this code can retrieve the client session id

you might license your program for lets say 2 ,4 , 6 , 8 etc etc users if
your program detects more session id`s as it has valid licenses , you can
then display a message
***************** Code Start **************
' Portions of this code have been copied from many sources
' including msdn. You are free to use it in any application.
'
' Compiled, modified and tested by Tom Malia and Habib Salim 3/14/2006
' Returns a Terminal Server Session ID and the Computer Name of a Terminal
' Server Client computer. Also use to detect if Terminal Server is running
' on a machine.
'**************
Option Explicit

Const WTS_CURRENT_SERVER_HANDLE = 0&

Private Declare Function WTSEnumerateProcesses Lib "wtsapi32.dll" _
Alias "WTSEnumerateProcessesA" _
(ByVal hServer As Long, _
ByVal Reserved As Long, _
ByVal Version As Long, _
ByRef ppProcessInfo As Long, _
ByRef pCount As Long) As Long

Private Declare Function WTSQuerySessionInformation Lib "wtsapi32.dll" _
Alias "WTSQuerySessionInformationA" _
(ByVal hServer As Long, _
ByVal SessionId As Long, _
ByVal WTSInfoClass As WTS_INFO_CLASS, _
ByRef ppBuffer As Long, _
pBytesReturned As Long) As Long

Private Declare Sub WTSFreeMemory Lib "wtsapi32.dll" _
(ByVal pMemory As Long)

Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(Destination As Any, _
Source As Any, _
ByVal Length As Long)

Private Declare Function GetCurrentProcessId Lib "kernel32" _
() As Long

Private Type WTS_PROCESS_INFO
SessionId As Long
ProcessId As Long
pProcessName As Long
pUserSid As Long
End Type

Public Enum WTS_INFO_CLASS
WTSInitialProgram
WTSApplicationName
WTSWorkingDirectory
WTSOEMId
WTSSessionId
WTSUserName
WTSWinStationName
WTSDomainName
WTSConnectState
WTSClientBuildNumber
WTSClientName
WTSClientDirectory
WTSClientProductId
WTSClientHardwareId
WTSClientAddress
WTSClientDisplay
WTSClientProtocolType
End Enum

Function TerminalServerClientID() As String
'MAIN FUNCTION
'Purpose : Returns the name of the Client Machine logged into to TS
'Inputs : N/A
'Outputs : Returns "N/A" if not a terminal server,
' "Unknown/Err" if an error occured
' else returns Computer Name of the client machine

Dim lRetVal As Long
Dim lThisSessionId As Long
Dim lThisProcessId As Long
Dim sBuffer As String
Dim lp As Long
Dim sClientName As String
Dim p As Long

On Error GoTo ErrNotTerminalServer
'Set Default Value
TerminalServerClientID = ""
lThisSessionId = 0
sBuffer = String(100, vbNullChar)

'Get the session id for the current user; if session id = 0 this is not
a TS session
lThisSessionId = TerminalServerSessionId

If lThisSessionId Then
'query TS for client Name
lRetVal = WTSQuerySessionInformation(WTS_CURRENT_SERVER_HAND LE,
lThisSessionId, WTSClientName, p, lp)
If lRetVal Then
'The client name has been passed to the buffer - now get it
back
Debug.Print GetStringFromLP(p)
sClientName = GetStringFromLP(p)
'sClientName = GetStringFromLP(sBuffer)- this causes a type
mismatch

Debug.Print sClientName
TerminalServerClientID = sClientName
Else
TerminalServerClientID = "UNKNOWN/ERR"
End If
Else
'This is not a TS Session
TerminalServerClientID = "N/A"
End If

Exit Function

ErrNotTerminalServer:
Debug.Print Err.Number; Err.Description
TerminalServerClientID = "UNKNOWN/ERR"

End Function

Function TerminalServerSessionId() As String
'Purpose : Returns a terminal server session ID
'Inputs : N/A
'Outputs : Returns "0" if not a terminal server, else returns the
terminal server session ID.

Dim lRetVal As Long
Dim lCount As Long
Dim lThisProcess As Long
Dim lThisProcessId As Long
Dim lpBuffer As Long
Dim lp As Long
Dim udtProcessInfo As WTS_PROCESS_INFO

On Error GoTo ErrNotTerminalServer
'Set Default Value
TerminalServerSessionId = "0"
lThisProcessId = GetCurrentProcessId
lRetVal = WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, 0&, 1,
lpBuffer, lCount)
If lRetVal Then
'Successful
lp = lpBuffer
For lThisProcess = 1 To lCount
CopyMemory udtProcessInfo, ByVal lp, LenB(udtProcessInfo)
If lThisProcessId = udtProcessInfo.ProcessId Then
TerminalServerSessionId = CStr(udtProcessInfo.SessionId)
Exit For
End If
lp = lp + LenB(udtProcessInfo)
Next
'Free memory buffer
WTSFreeMemory lpBuffer
End If

Exit Function

ErrNotTerminalServer:
'The machine is not a Terminal Server
On Error GoTo 0
End Function

Private Function GetStringFromLP(ByVal StrPtr As Long) As String
Dim b As Byte
Dim tempStr As String
Dim bufferStr As String
Dim Done As Boolean
Done = False

Do
' Get the byte/character that StrPtr is pointing to.
CopyMemory b, ByVal StrPtr, 1
If b = 0 Then ' If you've found a null character, then you're done.
Done = True
Else
tempStr = Chr$(b) ' Get the character for the byte's value
bufferStr = bufferStr & tempStr 'Add it to the string
StrPtr = StrPtr + 1 ' Increment the pointer to next byte/char
End If

Loop Until Done
GetStringFromLP = bufferStr

End Function


hth

Michel


"SilviaLl" <sllado@[NONECESARI]gmailDOTcomschreef in bericht
news:uO**************@TK2MSFTNGP02.phx.gbl...
Hola buenos dias,

Estoy haciendo un programa en VB 6 que se ejecutara en remoto con Terminal
Server o con CITRIX. Pero tengo que hacer un control de licencias, pensava
en hacer un control por el ordenador que està visualizando el programa. És
posible saber la dirección MAC o el serial del disco duro de ordenador que
esta visualizando el programa? Alguien tiene alguna sugerencia para que
solo el ordenador que se ha licenciado lo pueda ver?

Se agradece cualquier sugerencia,

Saludos cordiales,

SilviaLl.

Dec 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gomez,Martin | last post by:
como puedo crear un programa: que calcule la latitud, y altitud. como puedo ingresar graficos que se muevan a 360ª y se puedan acercar y alejar por medio de un icono o flecha....
0
by: Programas de email | last post by:
Convidamos você a experimentar o Magic Seven, o melhor programa de envio de emails para listas de contatos. Com o Magic Seven você pode enviar emails personalizados e com recursos multimídia,...
1
by: Liber | last post by:
Utilizando .Net, como puedo obtener la dirección ip o el nombre del cliente remoto que está conectado por Terminal Service a un Servidor de Terminal ? En el Terminal Servide Manager me muestra el...
0
by: alex,ocoro | last post by:
PROGRAMAS UTILIZADOS PARA HACKEAR NOMBRE DEL PROGRAMA DESCRIPCIÓN S.O. Cracker Jack 1.4 Descodificador de Passwords de Unix. Inglés.
2
by: =?Utf-8?B?S2V2aW4=?= | last post by:
I have autogeneratecolumns set to yes but the columns I am bound to to are not in the collection (using c#). How would I access them to set their wrap property to false. Please help I am...
5
by: diegososa | last post by:
I have this code inside a function: try: for linea in subprocess.Popen(comando, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stdout: req =...
0
by: Ranger | last post by:
TRANSFORME R$12,00 EM R$12.000,00 SÓ VAI TOMAR UM POUCO DO SEU TEMPO E VC Ñ VAI SE ARREPENDER ACREDITE!!! LEIA COM ATENÇÃO. MÉTODO APROVADO PELA REVISTA EXAME Você já imaginou ganhar até R$...
0
by: Ranger | last post by:
TRANSFORME R$12,00 EM R$12.000,00 SÓ VAI TOMAR UM POUCO DO SEU TEMPO E VC Ñ VAI SE ARREPENDER, ACREDITE!!! MÉTODO APROVADO PELA REVISTA EXAME Você já imaginou ganhar até R$ 12.000,00 ou mais,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.